开发者

Disable TextBox by checked Radio Button?

开发者 https://www.devze.com 2023-02-16 20:15 出处:网络
i created some javascript to disable input textbox when a radio button is checked and it works开发者_运维技巧 fine in firefox but in IE it doesn\'t work? What Can i Do?

i created some javascript to disable input textbox when a radio button is checked and it works开发者_运维技巧 fine in firefox but in IE it doesn't work? What Can i Do?

the example

function display_input(inputvalue)
{
    if(inputvalue == '1')
    {
        document.getElementById('time11').disabled = true;
        document.getElementById('time12').disabled = true;
        document.getElementById('date2').disabled = true;
    }
    else if(inputvalue == '2')
    {
        document.getElementById('time11').disabled = false;
        document.getElementById('time12').disabled = false;
        document.getElementById('date2').disabled = false;
    }

}


It's possible that IE doesn't run the code until the checkbox that was checked loses input focus. This is, I believe, how IE operates its onchange method. At the end of your display_input() function, try calling blur() on the checkbox:

function display_input(inputvalue)
{
  if(inputvalue == '1')
  {
    document.getElementById('time11').disabled = true;
    document.getElementById('time12').disabled = true;
    document.getElementById('date2').disabled = true;
  }
  else if(inputvalue == '2')
  {
      document.getElementById('time11').disabled = false;
      document.getElementById('time12').disabled = false;
      document.getElementById('date2').disabled = false;
  }
  // Blur focus on the checkbox...
  document.getElementById('theCheckBoxId').blur();
}
0

精彩评论

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

关注公众号