Leave Default Option Value Empty In Html Select
I have an html select that is populated with DATA from a query using a foreach loop. It looks something like this $client = $wpdb->get_results('SELECT string FROM `file` WHERE
Solution 1:
Add an empty option first:
echo '<selectname="client_list"><optionvalue=""></option>';
on submit if client_list
is empty you know someone didn't choose anything.
Solution 2:
you can use this
$client = $wpdb->get_results("SELECT string FROM `file` WHERE
`code` = 002 AND `status` = 2");
echo'Filter by client: ';
echo'<select name="client_list"><option value=""></option>';
foreach ($clientas$key => $row) {
$value = $row->string;
echo'<option value='.$value.'>'
.$value. '</option>';
}
$client = $_GET['client_list'];
echo'</select>';
Post a Comment for "Leave Default Option Value Empty In Html Select"