Jump to content


Photo

PHP print listbox values...?


  • Please log in to reply
3 replies to this topic

#1 dnienhaus

dnienhaus
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 31 July 2006 - 03:15 PM

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"?

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 31 July 2006 - 03:22 PM

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.

#3 dnienhaus

dnienhaus
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 31 July 2006 - 03:32 PM

What if i have 6 listboxes and each one has a value i need returned and then the values come together to form one part number?


can i do something like "$_POST['select_box_name', 'select_box_name', 'select_box_name']"?

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 31 July 2006 - 03:37 PM

In that case. Name each selectbox like this:
part[]
including the [] brackets. So you select box tag is like this:
<select name="part[]">
// options here
</select>

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users