Create multiple select box without javascript
For Creating multiple select box without javascript, follow the below steps.
Your html code will be like below,
<select multiple="multiple" name="element[]">
<!– dont forge to name this element as array means like "element[ ]" otherwise it will show only one value in post/get–>
<option value="1"> 1 </option>
<option value="2"> 2 </option>
<option value="3"> 3 </option>
<option value="4"> 4 </option>
</select>
If I elect 1 and 4 here then, You will retrieve the data in post or get what you may be using as method as below.
$_POST["element"] = array( [0] => 1 [1] => 4 );
Cheers! Mehul.






I am
about 1 year ago
This is a better solution than javascript. Good for you that you wrote this note.
about 1 year ago
This is a better solution than javascript. Good for you that you wrote this note.
about 1 year ago
Using multiple select box in php,after inserting the data to the Mysql data base , i want to retrieve back tat value for the purpose of edit. Can u Plz help me
about 1 year ago
@Anitha, if you are entering all selected values of selectbox as comma seperated in mysql database, than you can retrieve that field. Explode it and check for each selectbox value with database value if value is in database array than make it selected.
about 1 year ago
@Anitha, if you are entering all selected values of selectbox as comma seperated in mysql database, than you can retrieve that field. Explode it and check for each selectbox value with database value if value is in database array than make it selected.
about 1 year ago
Yes . It works.Thank you so much.
Regards,
Anitha.
about 1 year ago
Yes . It works.Thank you so much.
Regards,
Anitha.