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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variable from javascript prompt() to ASP page 1

Status
Not open for further replies.

Gail1111

MIS
Apr 8, 2003
8
0
0
US
I need to pass the variable 'yourname' that I capture in the javascript prompt() to an ASP, then have that variable placed inside an sql statement, followed by populating a form with the results of the sql statement. **I MUST populate the form with the data, including three different drop down boxes. Lost is putting it mildly, I do not know where to begin. However, I was considering passing the values from the sql statement into Session variables and assigning those variables to the form fields. How does that sound?


This is the function that I am using to capture the user Id.
function PassName()
{
yourname = prompt("Please enter your user ID", "");
setTimeout("top.location.href = '/CorrectInfo.asp'",250);
}
Response.Write &quot;<A HREF='javascript:passName()'>Click Here</A>&quot;

Your assistance is VERY much appreciated.
 
put the value of &quot;yourname&quot; into a form variable and submit the form to your asp page.
Code:
<html>
<head>
<SCRIPT LANGUAGE=javascript>
<!--
function PassName(){
	var yourname = prompt(&quot;Please enter your user ID&quot;, &quot;&quot;);
	document.getElementById(&quot;foo&quot;).value = yourname;
	document.getElementById(&quot;myform&quot;).submit();
}
//-->
</SCRIPT>
</head>
<body>
<form id=&quot;myform&quot; name=&quot;myform&quot; method=&quot;post&quot; action=&quot;mypage.asp&quot;>
<input type=&quot;text&quot; id=&quot;foo&quot; name=&quot;foo&quot; value=&quot;&quot;/>
</form>

-pete


 
palbano (Programmer)

What do I write on mypage.asp (second page) in order to use the variable from the sending page. I haven't been able to get that part working.


TY

Gail1111
 
Code:
<%
var userid = Request(&quot;foo&quot;);
%>

Also there is an ASP forum here at Tek-Tips for ASP questions. Click the &quot;Forum List&quot; link in the top left corner and you will find it in the list.

-pete

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top