Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    50
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question Get values from prompt and textbox in javascript. Problem.

    1) How can i get values from one page to another in javscript? Like, in php we use post and $_Post methods to move the values from one page to another. In the same way how can i move data between two pages in javascript?

    2) How can i get the value of prompt on another page? E.g.,
    prompt("What is your name?", "");

    Now, i want to get the value(i.e. answer of the question "What is your name?") and get that value to another page. How can i do this?

    Any help is greatly appreciated.

  • #2
    Regular Coder
    Join Date
    Sep 2011
    Posts
    128
    Thanks
    2
    Thanked 21 Times in 21 Posts
    The only easy way i know is:

    page1.php
    Code:
    <script type="text/javascript">
    var name = prompt("What is your name", "Type you name here");
    
    window.location = "page2.php?name"+name;
    </script>
    page2.php
    Code:
    <script type="text/javascript">
    alert("<?php echo $_GET['name']; ?>");
    </script>

  • Users who have thanked Wanna for this post:

    sunnynosid (09-20-2011)

  • #3
    New Coder
    Join Date
    Sep 2011
    Posts
    50
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks a lot wanna. It's very useful for me.


  •  

    Tags for this Thread

    Posting Permissions

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