Jump to content

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.