开发者

empty value of element in IE

开发者 https://www.devze.com 2023-01-16 22:38 出处:网络
This code in firefox is working. In IE the alert is empty. <select id=\"ronny\"name=\"ronny\" onchange=\"AjaxPost();alert(document.getElementById(\'ronny\').value);\">

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

精彩评论

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

关注公众号