SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Passing string between pages

    I'm trying to pass one string from a page to another page. Is this possible with java script??

    -habeeb-

  2. #2
    SitePoint Addict NikoB's Avatar
    Join Date
    Nov 2005
    Location
    Austria
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sure....

    There are numerous way of passing a string, you can send it over get ( site.html?var=string) using direct variable passing (var wnd = window.open("site.html"); wnd.var = 'string') or pulling ( alert(opener.var); )

    It all depends on what you want to accomplish (run-time variable passing/on load/which page passes to which and so on)...
    Corinis OpenSource Community & Content Management
    http://www.corinis.org

  3. #3
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank u for the reply.

    I want to collect name of a person from one page and it will display on the second page.

    how can i display the information on the second page??

    thanks
    -habeeb-

  4. #4
    SitePoint Addict NikoB's Avatar
    Join Date
    Nov 2005
    Location
    Austria
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you mean like a contact info.. where you have a form for the user to input the name?
    try:
    Code:
    <html>
    <body>
    <form method="get" action="page2.html">
    <input name="name">
    <input type="submit">
    </form>
    </body>
    </html>
    Code:
    <html>
    <body>
    Hello <script>
    // get the name from the location
    var name = document.location.href.substring(document.location.href.indexOf("name="));
    document.write(name);
    </script>
    </body>
    </html>
    this has to be tweaked a little (like do a better parsing, unescape the url) but I ope you get the basic idea..
    Corinis OpenSource Community & Content Management
    http://www.corinis.org

  5. #5
    SitePoint Guru momos's Avatar
    Join Date
    Apr 2004
    Location
    Belgium
    Posts
    919
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could put it in cookies too, beware though, cookies can be refused, javascript can be disabled!


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
  •