Jump to content

PHP print listbox values...?


dnienhaus

Recommended Posts

I have some listboxes that a user will select values from and in turn it is supposed to take the selected value and print as strings to form a part number. I have all the boxes made but how can i return the value of an option selected in the list menu?

i.e. <option value="L">Clutch Pedal Assy</option>

how would i return or print to screen "L"?
Link to comment
https://forums.phpfreaks.com/topic/16110-php-print-listbox-values/
Share on other sites

You'll want to give aname to the selectbox tag for your listboxes. then when you submit your form you use $_POSt['select_box_name']
Changing select_box_name to the name of your select box. If its a multi listbox you'll want to add [] at the name of your select box name.
In that case. Name each selectbox like this:
part[]
including the [] brackets. So you select box tag is like this:
[code]<select name="part[]">
// options here
</select>[/code]

then  use a foreach loop like so:
[code]$partNumb = '';
foreach($_POST['part] as $part_k => $part_v)
{
    $partNumb .= $part_v;
}
echo "Your partNumber is: {$partNumb}";[/code]
That will then loop through each part selectbox and generate the 6 character part number.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.