Jump to content

ComboBox


nh_phpcoder

Recommended Posts

hello,

 

i need to create a select "combo box" in html with php that contains the following format as an example:

 

select:0_None:Al_Al-Aluminum:S_S-Steel:W_W-Wood:O_O-Other

 

the combo box to be created:

 

<select name"myselect">

<option value="Al">Al-Aluminum></option>

<option value="Al">S-S-Steel></option>

<option value="W">W-Wood></option>

<option value="O">O-Other></option>

</select>

 

thanks for any help

Link to comment
https://forums.phpfreaks.com/topic/200124-combobox/
Share on other sites

You could use something like this...

 

$input = 'select:0_None:Al_Al-Aluminum:S_S-Steel:W_W-Wood:O_O-Other';
$parts = explode(':', $input);

if($parts[0] == 'select') {
   echo '<select name="myselect">'."\r\n";
   for($i = 1; $i < sizeof($parts); $i++) {
      echo '<option value="'.strtok($parts[$i], '_').'">'.strtok('_').'</option>'."\r\n";
   }
   echo '</select>';
}

Link to comment
https://forums.phpfreaks.com/topic/200124-combobox/#findComment-1050483
Share on other sites

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.