Disable TextBox by checked Radio Button?
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();
}
精彩评论