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