Connecting Tech Pros Worldwide Forums | Help | Site Map

Passing variables from Javascript to ASP

Consuelo Guenther
Guest
 
Posts: n/a
#1: Jul 19 '05
Hello,
I am having problems with passing variables between pages. I have the
following:
First asp page has the function:
-----------------------------------------------------------------------
<script language="JavaScript">
function addProcess(addPName,addSProcess,addPIndex)
{
var addProcessWindow =
window.open('second.asp','mywindow','width=400,hei ght=200');
addProcessWindow.focus();
return(true);
}
</script>
--------------------------------------------------------------------------------------------
There is button (not in a form) that is clicked and calls the function above.
The variables addPName,addSProcess, and addPIndex are the variables I need
to pass and be able to reference on to the page 'second.asp'.
For now, all I am trying to do is to verify if the values are being passed
to my 'second.asp' page. How can I retrieve the values in the page
below?--------------------------------------------------------------------------------------------
<%@ LANGUAGE="JScript" %>
<html>
<head>
<title>Second</title>
<%
Response.Write ???? -> variables here...
%>
</head>
<body>
</body>
</html>
----------------------------------------------------------------------------------------------
Please help!
Thanks. :-)


Ray Costanzo [MVP]
Guest
 
Posts: n/a
#2: Jul 19 '05

re: Passing variables from Javascript to ASP


Pass them in the querystring. Example:

yourpage.asp:
<html>
<head>
<script language="JavaScript">
function addProcess(addPName,addSProcess,addPIndex)
{

var addProcessWindow = window.open('second.asp?a='+addPName + '&b=' +
addSProcess + '&c=' + addPIndex,'mywindow','width=400,height=200');
addProcessWindow.focus();
return(true);
}
</script>
</head>
<body>
<button onclick="addProcess('Hi ','there ','Consuelo');">Click me</button>
</body>
</html>


second.asp:
<%
Response.Write Request.Querystring("a") & Request.Querystring("b") &
Request.Querystring("c")
%>


Note that you don't have to use "a," "b," and "c." You can do
'second.asp?whateveryoulike=' + addPName....

Ray at home




"Consuelo Guenther" <ConsueloGuenther@discussions.microsoft.com> wrote in
message news:CAD34D74-17AB-4522-AFB2-79EA209DA4CE@microsoft.com...[color=blue]
> Hello,
> I am having problems with passing variables between pages. I have the
> following:
> First asp page has the function:
> -----------------------------------------------------------------------
> <script language="JavaScript">
> function addProcess(addPName,addSProcess,addPIndex)
> {
> var addProcessWindow =
> window.open('second.asp','mywindow','width=400,hei ght=200');
> addProcessWindow.focus();
> return(true);
> }
> </script>
> --------------------------------------------------------------------------------------------
> There is button (not in a form) that is clicked and calls the function
> above.
> The variables addPName,addSProcess, and addPIndex are the variables I need
> to pass and be able to reference on to the page 'second.asp'.
> For now, all I am trying to do is to verify if the values are being passed
> to my 'second.asp' page. How can I retrieve the values in the page
> below?--------------------------------------------------------------------------------------------
> <%@ LANGUAGE="JScript" %>
> <html>
> <head>
> <title>Second</title>
> <%
> Response.Write ???? -> variables here...
> %>
> </head>
> <body>
> </body>
> </html>
> ----------------------------------------------------------------------------------------------
> Please help!
> Thanks. :-)
>[/color]


Closed Thread