SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting HTTP VARS

    I have a little problem.
    I want to get the variables which are passes through from one page to another.

    I.e. I have a form on one page which posts (method="post") a variable 'TEST' to another page.

    In the second page I want to use this variable in a form.

    Can this be done, and if so: HOW?

    Any help is appreciated!

    Jazz

  2. #2
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    I don't believe that can be done with JavaScript, POST variables can only be read by a server-side language (PHP,, CFM, .NET). JavaScript can read the querystring (GET) however so maybe try that. Unfortunately I don't know how to get variables from there though

  3. #3
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code:
    theURL = location.href;
    if (theURL.indexOf("?") > -1) {
      els = theURL.split("?");
      if (els.length == 1) {
        theQS = els[1];
      } else {
        theQS = "";
      }
    } else {
      theQS = "";
    }
    Perhaps??? If the current page (location.href) is "http://www.domain.com/page.htm?item1=value1&item2=value2" then theQS will contain "item1=value1&item2=value2". Obviously you can split() again on "&" to get each argument.
    Ian Anderson
    www.siteguru.co.uk


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •