Re: Passing variables from Javascript to ASP

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ray Costanzo [MVP] (my)
Date: 09/22/04


Date: Tue, 21 Sep 2004 20:38:24 -0400

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...
> 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,height=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. :-)
>



Relevant Pages

  • Re: More than a single script block within a single HEAD and BODY
    ... Can there be more than a single script block in a given HEAD tag? ... The W3C HTML validator lets you paste markup directly into the validation form. ...
    (comp.lang.javascript)
  • RE: Moving Data
    ... * I need to collect the input data on exampl1.aspx by hitting the review button. ... <script runat="server"> ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: newby Q about using Google Maps with ASP.Net 2.0
    ... Google recommends placing the script in the head and then running it ... In master pages you could conceivably add the script to the head ... ASP.Net does is render HTML to a browser from the server (all that you need ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: What am I doing wrong in updating other frames
    ... (no other frameset file opened in one of your frames) ... "http://www.w3.org/TR/html4/frameset.dtd"</a>;> <HEAD> Table of ContentsIndex ... or other type if script is other than JS ...
    (comp.lang.javascript)
  • Re: SMTP delivery options.
    ... > Thanks anyway Ray I found the script elsewhere. ... >> some SMTP products allow for converting plain text messages to HTML, ... >> allows you to convert plain text to HTML at delivery time. ...
    (microsoft.public.scripting.vbscript)