julian9876 Posted May 16, 2011 Share Posted May 16, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/236554-multiple-select-list-boxes/ Share on other sites More sharing options...
Maq Posted May 16, 2011 Share Posted May 16, 2011 Post some code. Quote Link to comment https://forums.phpfreaks.com/topic/236554-multiple-select-list-boxes/#findComment-1216064 Share on other sites More sharing options...
julian9876 Posted May 16, 2011 Author Share Posted May 16, 2011 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>"; } Quote Link to comment https://forums.phpfreaks.com/topic/236554-multiple-select-list-boxes/#findComment-1216070 Share on other sites More sharing options...
julian9876 Posted May 16, 2011 Author Share Posted May 16, 2011 Done it!! 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!!!! Quote Link to comment https://forums.phpfreaks.com/topic/236554-multiple-select-list-boxes/#findComment-1216075 Share on other sites More sharing options...
Maq Posted May 16, 2011 Share Posted May 16, 2011 In the future, please place tags around your code. Quote Link to comment https://forums.phpfreaks.com/topic/236554-multiple-select-list-boxes/#findComment-1216077 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.