Forum Moderators: coopster
I have a drop down which is generated by an array with a list of numbers.
I am trying to use the selected number for a calculation: $hours * 10. However, I am not sure how to pull the selected number out.
Below is my code:
<select class="select" id="hours" name="hours">
<option value="0" selected="selected">Hours</option>
<?
foreach ($hours as $key => $value)
{
echo "<option value='$key'>$value</option>\n";
}
?>
</select>
Any help with this would be greatly appreciated.
Cheers in advance.
<select class="select" id="hours" name="hours">
<option value="0" selected="selected">Hours</option>
The key for the $_POST array will be the id/name. The value will either be the value if you specify one, or if you dont then it will be the contents of that option.
So if you had -
<select class="select" id="hours" name="hours">
<option value="0" selected="selected">0 Hours</option>
<option value="10" selected="selected">10 Hours</option>
<option value="15" selected="selected">15 Hours</option>
<option value="500" selected="selected">500 Hours</option>