开发者

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 this by document.getElementById('ronny') :

onchange="AjaxPost();alert(document.getElementById('ronny').options[selectedIndex].value);"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜