SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Passing Values

  1. #1
    SitePoint Enthusiast Zero G's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing Values

    Is there a way to pass the value of some variables from one page to another? and if so how.

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Fort Lauderdale
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can pass it in the querystring like this

    http://www.yourpage.com/test.html?x=1&y=2

    Now you have the variables x and y in the url, so you have to parse the url.

    Code:
    <script>
    			querystring = window.location.search.substring(1);
    			pairs = querystring.split("&");
    			keys = new Array(); values = new Array();
    			for (i = 0; i < pairs.length; i++) {
    				keys[i] = pairs[i].substring(0, pairs[i].indexOf("="));
    				values[i] = pairs[i].substring(pairs[i].indexOf("=") + 1, pairs[i].length);
    			}
    </script>
    Now you have two arrays, keys which stores the variable names(x, y) and values which stores the variable values(1, 2).

    www.unpossiblemedia.com - A Fort Lauderdale based multimedia company.

  3. #3
    SitePoint Enthusiast Zero G's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks I thought it was something like that because thatís how it is with .php pages but I didnít know if it was the same for .html

  4. #4
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wrote a tiny javascript class for handling query-string data. I keep an active demo page here

    http://www.peterbailey.net/dhtml/for...ew.htm?x=1&y=2
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  5. #5
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey that's some very nice work, beetle!

  6. #6
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Mike. [img]images/smilies/blush.gif[/img]

    You'd probably like some of my other classes, and even some that aren't done.

    None of them are terribly well documented. Something I hope to remedy soon.

    </commercial>

    [img]images/smilies/goof.gif[/img]

    I've been meaning to mess around with your cross-browser stuff, just haven't had the time
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  7. #7
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep I agree, time is in short supply lately.

    I like the Map Plotter - that's slick

    TAEditor is very nice. It even detects improper nesting!

    Great stuff!


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
  •