Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a Value From Popup Window to a Form 1

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
US
Hello,

I have a JavaScript that asks for the user name, if the field is empty it does not let the user get in, if the user fills out his/her name it let's them in to the Form.

I have a script that is supposed to pass the username to a field in my form. Not sure what i am doing wrong because it is not passing the username.
here is what I have so far
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]


<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript">
temp= window.prompt ("Please Type Your Name" , "");
if (temp=="")  { window.location="[URL unfurl="true"]http://wrongpage.htm";}[/URL] 
</script>

<script>
function initialize()
{
 document.forms['form'].elements['username'].value = temp ;
}
</script>






</head>

<body>
 <form name="form" method="post" action="update_entry00.asp">
<input name="category" type="text" value="Category1" />
<input name="questionid" type="text" value="1" />
<input name="questions" type="text" value="What color do you like?" />


<input name="answer" type="text" value="" />

<input name="username" type="text" value="<% = Response.Write(Request.QueryString("temp"))%>" readonly="true" />


<p>
  <input type="submit" name="Submit"   value="submit"></p>
</form>
</body>
</html>
 
Hi

Your initialize() function is never called.

Anyway, why a function there ? temp gets value only once, so assigning it to a [tt]form[/tt] field is enough to be done once. Just remove the [tt]function[/tt] around that assignment.

Feherke.
 
[0]
>value="<% = Response.Write(Request.QueryString("temp"))%>"
[tt]value="<% = Request.QueryString("temp"))%>"[/tt]

[1]
[tt]<script>
function initialize()
{
document.forms['form'].elements['username'].value = temp ;
}
[red]window.onload=initialize;[/red]
</script>[/tt]
 
Thanks!! I got it!!!

Appreciate the help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top