form submission with Javascript

Discussion in 'JavaScript' started by ktsirig, Dec 18, 2006.

  1. #1
    Hello!
    I am searching over the net for quite a long, but I have almost no idea concerning Javascript so I can't figure out the solution to my problem...
    I have a form that show a drop-down menu, which takes all its values through a Mysql database via PHP. What I want to do is to submit the form to the next page (from index.php ---> retrieve_data.php) without the need of a "Submit" button.
    When the user selects one of the given options, automatically he will be redirected to retrieve_data.php?id=5 for example...

    Thank you in advance!
     
    ktsirig, Dec 18, 2006 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,811
    Likes Received:
    4,535
    Best Answers:
    123
    Trophy Points:
    665
    #2
    sarahk, Dec 18, 2006 IP
  3. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #3
    
    <form action="retrieve_data.php" method="get">
    <select name="id" onChange="submit()">
    <!-- Im aware your values are from sql, 
    	 Im just giving you the general idea -->
    <option> Please choose whatever </option>
    <!-- Remember to leave the line above in
         its vital to full operation		 -->
    <option value="1">Stage 1</option>
    <option value="2">Stage 2</option>
    </select>
    </form>
    
    Code (markup):
     
    krakjoe, Dec 18, 2006 IP
    sarahk likes this.
  4. weknowtheworld

    weknowtheworld Guest

    Messages:
    306
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Better use AJAX...
     
    weknowtheworld, Dec 20, 2006 IP
  5. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #5
    Read the post properly......ajax isn't needed at all, not even a little bit.
     
    krakjoe, Dec 20, 2006 IP