Trouble with select / option tag and PHP

Discussion in 'PHP' started by blogfisher, Dec 7, 2008.

  1. #1
    After wasting couple of hours on google.com for searching solution, i came here with hope to get quick reply. Well, i am developing an application in php. I am not sure how to access option tag value using php. My code snippet is as below:

    echo '<select name="number" action="next.php" method="post">';
    for ($i=1; $i <=10; $i++) {
       echo "<option value ='$i'>$i</option>";
    }
    echo '</select>';
    Code (markup):
    This basically shows you a drop-down list from 1 to 10. User can choose any one of them. As soon as user choose one of the option, i wan to pass the value to another file next.php. I dont want to use submit button. It should pass automatically.

    I don't know how to do this.

    Quick reply will be highly appreciated.

    Thanks in advance.
     
    blogfisher, Dec 7, 2008 IP
  2. mac83

    mac83 Active Member

    Messages:
    237
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #2
    echo '<form name = "formname" method="post" action ="next.php">';
    echo '<select name="number" onchange="form.submit()">';
    for ($i=1; $i <=10; $i++) {
    echo "<option value ='$i'>$i</option>";
    }
    echo '</select> </form>';
     
    mac83, Dec 7, 2008 IP
  3. blogfisher

    blogfisher Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks a lot Mac83.. it works... u are better than Google :)
     
    blogfisher, Dec 7, 2008 IP