Passing variables from Javascript to ASP

Discussion in 'ASP General' started by Consuelo Guenther, Sep 22, 2004.

  1. 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. :)
     
    Consuelo Guenther, Sep 22, 2004
    #1
    1. Advertising

  2. 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" <> wrote in
    message news:...
    > 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. :)
    >
     
    Ray Costanzo [MVP], Sep 22, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    9
    Views:
    1,008
  2. Gung Ho
    Replies:
    2
    Views:
    153
    Fatbob
    Nov 28, 2003
  3. El Durango

    passing javascript variables to JSP

    El Durango, Aug 11, 2004, in forum: Javascript
    Replies:
    1
    Views:
    146
    kaeli
    Aug 11, 2004
  4. Replies:
    2
    Views:
    114
    Randy Webb
    Feb 19, 2005
  5. Replies:
    1
    Views:
    159
Loading...

Share This Page