empty value of element in IE
This code in firefox is working. In IE the alert is empty.
<select id="ronny" name="ronny" onchange="AjaxPost();alert(document.getElementById('ronny').value);">
<option id="selected_ronny">All</option>
<?php
foreach($d_ronny as $ronny)
{
if ($ronny == $_POST['ronny_select'])
{
开发者_JAVA技巧echo "<option selected id='selected_ronny'>$ronny</option>";
}
else
{
echo "<option>$ronny</option>";
}
}
?>
</select>
The options are fox example :
All
abc
123
xyz
When i select xyz
, the alert shows xyz
. In IE the alert is empty.
thank you!
For the onchange attribute you have to code like this :
onchange="AjaxPost();alert(this.options[selectedIndex].value);"
If you want to use the id, replace thi
s by document.getElementById('ronny')
:
onchange="AjaxPost();alert(document.getElementById('ronny').options[selectedIndex].value);"
精彩评论