Jump to content

Multiple Select List Boxes


julian9876

Recommended Posts

Hello....

I have a form that has a multiple select list box on it...

When i display all the data from the list box, all i get is the number of the option that i have selected.

Does anyone know how to change the value from a number to a name???

 

Julian

Link to comment
Share on other sites

This is the listbox:

 

<fieldset>
<legend>Optional extras</legend>
<select class="select" id="extras" name="options[]" multiple="multiple" size="6">
<optgroup label="Entertainment">
<option value="1">6 disc DVD changer</option>
<option value="2">TV function</option>
<option value="3">DAB digital radio</option>
<option value="4">Loudspeaker system - professional </option>
<option value="5" title="Multimedia navigation system. Uses advanced audio technology">Multimedia navigation system</option>
</optgroup>
<optgroup label="Communication">
<option value="6">Universal remote control</option>
<option value="7">Voice control</option>
<option value="8">Navigation system</option>
<option value="9">Head-up display</option>
</optgroup>
<optgroup label="Safety and Security">
<option value="10">Adaptive headlights</option>
<option value="11">Night vision with pedestrian recognition</option>
<option value="12">Run-flat tyres</option>
</optgroup>
</select>
</fieldset>

Only code i have for the php:

 

if( is_array($car_extras))
{
while (list ($key, $val) = each ($car_extras)) 
{
echo "$val <br>";
}

 

 

Link to comment
Share on other sites

Done it!!  :D

 

if( is_array($car_extras))
{
while (list ($key, $val) = each ($car_extras))
{
if($val==0){echo("6 disc DVD changer");}
elseif($val==1){echo("TV function<br />");}
elseif($val==2){echo("DAB digital radio<br />");}
elseif($val==3){echo("Loudspeaker system - professional<br />");}                               
elseif($val==4){echo("Multimedia navigation system<br />");}
elseif($val==5){echo("Universal remote control<br />");}
elseif($val==6){echo("Voice control<br />");}
elseif($val==7){echo("Navigation system<br />");}
elseif($val=={echo("Head-up display<br />");}
elseif($val==9){echo("Adaptive headlights<br />");}
elseif($val==10){echo("Night vision with pedestrian recognition<br />");}
elseif($val==11){echo("Run-flat tyres<br />");}
}

}

 

Thanks anyway!!!!

Link to comment
Share on other sites

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.