Page 1 of 1

Post different data to what is show in a html select input

Posted: Fri Mar 12, 2010 4:00 pm
by lshaw
I have a drop down list stored in a database, but when the user submits data I need to submit the id of the record, not the actual value or I will have duplicative data

Example:

Code: Select all

 
//fetch array code etc.
//while loop {
    echo "<option>$array['name']</option>"; //show the option list
    //what I want to submit is the $array['id'] of the name they selected. 
}
 
I know this could be done with ajax by updating a hidden fieild when the value of the select is changed, but i dont what to use ajax.

Thanks for your help

Lewis

Re: Post different data to what is show in a html select input

Posted: Fri Mar 12, 2010 4:13 pm
by AbraCadaver
Maybe?

Code: Select all

echo "<option value=\"{$array['id']}\">{$array['name']}</option>";