Passing all <option> from <select> to php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ang Talunin

    Passing all <option> from <select> to php

    Hey,

    I wondering if it's possible to retrieve all the <option>-fields from a
    <select> when posting a <form> to a php file

    Example:
    I've got a form like this:

    <form action = phpfile.php method=post >
    <select name= "name">
    <option value="1">1</option>
    <option value="2">2</option>
    </select>
    </form>

    and a php file where i retrieve the posted date:

    $name=$_POST["name"];

    but how can i get the value of option 1 and option 2 no matter if they are
    selected or not?

    Anybody knows?


  • Lee

    #2
    Re: Passing all &lt;option&g t; from &lt;select&g t; to php

    Ang Talunin said:[color=blue]
    >
    >Hey,
    >
    >I wondering if it's possible to retrieve all the <option>-fields from a
    ><select> when posting a <form> to a php file[/color]

    It might help to know why your PHP script cares about the
    options that haven't been selected.

    If the options aren't likely to ever change, hard code them
    into your PHP script. If they are generated dynamically,
    you could also create a hidden form field that lists all of
    the options.

    Comment

    Working...