Sending values from server side to Client side javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Renuka

    Sending values from server side to Client side javascript

    Hello,

    Can someone help me with the following situation??

    I have a Hyperlink within a String like below:

    sSql = "SELECT DISTINCT " + "'Action' = '<center><a
    href='+char(34) +'ChangeRequest .aspx?ID='+cast (ChangeRequest. ChangeRequest_I D
    as nvarchar) +CHAR(34)+'>Ope n</a></center>',"

    I want to invoke a Client side javascript function and pass the value
    of the ID. How can I accomplish this such when a user clicks "Open" he
    goes to a new window with the same ID.

    I tried this but it does not work:
    On Server side:
    sSql = "SELECT DISTINCT " + "'Action' = '<center><a href= 'javascript:
    NewWindow('+cas t(ChangeRequest .ChangeRequest_ ID as nvarchar)+
    CHAR(34)+)'>Ope n</a></center>',"

    On Client side:
    function NewWindow(myID)
    {
    window.open("Ch angeRequest.asp x?ID="+myID,"Wi ndowName","widt h=500,height=60 0");
    }
    </script>
  • Michael Winter

    #2
    Re: Sending values from server side to Client side javascript

    "Renuka" wrote on 13/11/2003:
    [color=blue]
    > Hello,
    >
    > Can someone help me with the following situation??
    >
    > I have a Hyperlink within a String like below:
    >
    > sSql = "SELECT DISTINCT " + "'Action' = '<center><a
    >[/color]
    href='+char(34) +'ChangeRequest .aspx?ID='+cast (ChangeRequest. ChangeRequ
    est_ID[color=blue]
    > as nvarchar) +CHAR(34)+'>Ope n</a></center>',"
    >
    > I want to invoke a Client side javascript function and pass the[/color]
    value[color=blue]
    > of the ID. How can I accomplish this such when a user clicks "Open"[/color]
    he[color=blue]
    > goes to a new window with the same ID.
    >
    > I tried this but it does not work:
    > On Server side:
    > sSql = "SELECT DISTINCT " + "'Action' = '<center><a href=[/color]
    'javascript:[color=blue]
    > NewWindow('+cas t(ChangeRequest .ChangeRequest_ ID as nvarchar)+
    > CHAR(34)+)'>Ope n</a></center>',"
    >
    > On Client side:
    > function NewWindow(myID)
    > {
    >[/color]
    window.open("Ch angeRequest.asp x?ID="+myID,"Wi ndowName","widt h=500,heig
    ht=600");[color=blue]
    > }
    > </script>[/color]

    You are trying to launch a pop-up window with URL that is generated
    server-side. If so, have your server-side script produce this link:

    <A href="#"
    onclick="window .open('ChangeRe quest.aspx?ID=I NSERT-YOUR-ID-VALUE-HERE'
    , 'your-window-name', 'width=500,heig ht=600')">Open</A>

    Mike

    --
    Michael Winter
    M.Winter@[no-spam]blueyonder.co.u k (remove [no-spam] to reply)


    Comment

    Working...