#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    4
    Rep Power
    0

    How to pass variables from javascript on one htm page to another asp page?


    I'm trying to pass more than one variable from javascript to another asp page. I used Array to transfer multiple vars into one var (named "words"). Here is the relevant code I tried:

    <SCRIPT language=Javascript>
    <!--
    function query()
    {
    var words=" ";
    for (i=0; i<=10; i++)
    {
    {if (document.pref_form.elements[i].checked)
    words = words + " + AND + " + prefArray[i];}
    }

    How can I pass the var "words" to another asp page (say, search.asp)? In that search page, I want to use the received words to conduct a key word search. Please help me!!! Thax a lot!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    No es importante
    Posts
    2,065
    Rep Power
    14
    You can pass the variables via the post method and have the recieving page accept the variables. Depending on your server and your experience you could use sessions as well.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    8
    Rep Power
    0
    Hi,

    i had the same problem. What i did is creating hidden field(s) with javascripts on my page.

    This is something i created for transferring some products:

    HiddenHTML = '<form name="frmProduct" method="POST">'
    HiddenHTML += '<input name="Code' + i + '" type="hidden" value="' + arrCode[i] + '">'
    HiddenHTML += '<input name="Oms' + i + '" type="hidden" value="' + arrOms[i] + '">'
    HiddenHTML += '<input name="Prijs' + i + '" type="hidden" value="' + arrPrijs[i] + '">'

    HiddenHTML += '<input name="Totaal" type="hidden" value=' + total + '>'
    HiddenHTML += '<input name="AantalVelden" type="hidden" value=' + i + '>'
    HiddenHTML += '</form>'


    Put it in a div with this :

    document.all["HiddenProducts"].innerHTML = HiddenHTML


    And put this somewhere on your page

    <div id="HiddenProducts"></div>

    And create a button and call a function with some thing like this:

    document.frmProduct.action = "<somepage.asp>"
    document.frmProduct.submit();

    there some dutch words involved but i think you well get the main idea from this.

    greetz,
    Hennie

IMN logo majestic logo threadwatch logo seochat tools logo