how can choose SELECT tag from a form if there are multiple SELECT tags?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nixan
    New Member
    • Apr 2008
    • 4

    how can choose SELECT tag from a form if there are multiple SELECT tags?

    Hai all im new to this forum and begin to learn php.

    Here is a problem which may be very simple to you but it is problem to me.
    how can choose SELECT tag from a form if there are multiple SELECT tags?
    for example[code=html]<form name="form" id="form" action= "page2.php" >
    <select name="name1" id="id1" onchange="">
    <option>item1 </option>
    </select>
    <select name="name2" id="id2" onchange="">
    <option>item1 </option>
    </select>
    <select name="name3" id="id3" onchange="">
    <option>item1 </option>
    </select>

    </form>[/code]

    How can i select SELECT tag for ex name2 in page2.php?

    Thanks for advance.
    Last edited by ronverdonk; Apr 2 '08, 12:23 PM. Reason: code tags!!
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Welcome to Bytes!

    Please enclose your posted code in [code] tags (See How to Ask a Question).

    This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

    Please use [code] tags in future.

    MODERATOR

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Looking at your form, you can say that the form is submitted using the GET (default form option). So the values are in the $_GET array of the second script. Printing out that array you'll see the following structure
      Code:
      Array
      (
          [name1] => item1
          [name2] => item1
          [name3] => item1
      )
      So, in your "catchting" script, you test the selection of an option in the select box named name1 by verifying its presence in the $_GET array as follows:[php]if (isset($_GET['name2'])
      $var_2=$_GET['name2']; // now $var_2 contains the value 'item2'[/php]And you are aware of the difference between multiple select tags, as in: multiple <select> statements and multiple-select tags, as in:multiple options in 1 select box?

      Ronald

      Comment

      Working...