Hi, I have a php script with an array which loops through months and displays them in a drop down. I want to get the selected value from the drop down using javascript.
function month_list()
{
$months = Array("January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December");
echo '<select name="month" id="month_list" OnChange="getvalue();">';
foreach ($months as $months => $month)
{
echo'<option OnChange="getvalue();" value='.$month.'>'.$month.'</option>';
}
echo '</select>';
}
Javascript:
<script type="text/javascript">
function getvalue()
{
alert(document.getElementById((month_list)).value);
}
</script>
Nothing happends when I select a value but in firebug I get the error:
Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead.
Any advice?
Thanks.