Passing a variable to a new window

Results 1 to 2 of 2

Thread: Passing a variable to a new window

  1. #1
    Aaron Bird Guest

    Default Passing a variable to a new window

    I may be doing this all wrong but here is what I am trying to do. I want the user to type into the first text box and then when the button is clicked I need to use that variable (tnum) to pass to the OpenWindow function. I didn&#039t know if I should make it a form or like I have it.<BR><BR>Thanks,<BR>Aaron<BR><BR>&#060;input type="text" name="tnum" size="10" maxlength="10" value=""&#062;<BR>&#060;input type = "button" name = "open" value = "Open Window" onClick = "return OpenWindow(&#039editticket.asp?ticket=&#060;%="TNU M"%&#062;&#039);"&#062;<BR><BR>-----------------------<BR>function OpenWindow(url)<BR>{<BR>var hWnd =,"","width=650,height=500,resizable =no,scrollbars=no");<BR> if (!hWnd.opener) hWnd.opener = self;<BR>}<BR>--------------------<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Passing a variable to a new window

    Two things wrong with that:<BR><BR>(1) The user might type something in the text box that won&#039t be legal in the URL.<BR>(2) You aren&#039t referring to the text field in a legal manner.<BR><BR>(and you don&#039t need the return from the function call--it doesn&#039t do anything...not that you were actually returning anything, anyway.)<BR><BR>*************<BR><BR>So all you need to do is:<BR><BR>&#060;input type = "button" name = "open" value = "Open Window" <BR>&nbsp; &nbsp; onClick = "OpenWindow(&#039editticket.asp?ticket=&#039+escap e(this.form.tnum.value));"&#062;<BR><BR>Be careful! JS code is case sensitive. You can&#039t use name="tnum" and then user TNUM.value. Will never work.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts