Check checkbox on textbox focus
I want to check a checkbox when a user places the cursor on a text box. I
want to achieve this using pure javascript. I tried the following code:-
HTML code:
<input name="containText" TYPE="text" size = "32"
onfocus="checker('contain')" />
<input type = "checkbox" name = "contain" />
Javascript code:
function checker(checkbox) {
var checkBox=document.form.contain;
checkBox.checked = true;
}
The code is not working. I am a beginner in Javascript so please bear with
me.
No comments:
Post a Comment