0
我有一个php脚本,它的数组循环遍历数月,并在下拉菜单中显示它们。我想使用javascript从下拉列表中选择值。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>
没有happends但萤火我得到的错误:
Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead.
有什么建议?
谢谢。
谢谢!噢,我忘了我把那部分留在了:) – Elliott 2010-09-22 20:19:00