Onclick of a button in javascript does not do anything on IE9
The issue is,
I am trying to click on the function set, and when i click Ok afer i get the alert ,it does not fill the text field test for me.This works fine on IE 7 and IE8.I was trying to test on IE9 and it does not do anything.Can anyone point me in the right direction.
function setTest(x)
{
document.add(x).value = "this is a test value";
}
</SCRIPT>
The HTML code is as follows
<td>
<input type="text" name="test" id="test" size="10" value="<?php echo $test;?>">
<input type="button" value="FILL" class="submit" onClick="if( confirm( 'Are you sure you want to set th开发者_如何转开发is field.') ){ setTest('test'); }">
</td>
Thanks in advance.
I've no idea what document.add
is supposed to do, but if you want to set the value of that input
field it looks like you actually want getElementById
:
function setTest(x) {
document.getElementById(x).value = "this is a test value";
}
Example on jsfiddle.
精彩评论