0

Hello people,

I want that when I mouse over a checkbox, that it is checked.

I have now the following code:

<script language=javascript>
function checkit(myform, name)
{
var xx = document.myform.name;
xx.checked = true;
}
</script>

<form name=myform27>
<input type=checkbox name=mycheck onMouseOver="checkit(myform27,mycheck)" value="1"> Checking
</form>

But this does not work, it says "document.myform is undefined".

How to solve this, and what are i am doing wrong?

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by kvdd
Featured Replies
  • Or you can just simplify things by doing this: [code=html]<form name="myform27" action="#" onsubmit="return false;"> <label for="chk1"> <input type="checkbox" name"myCheck" id="chk1" onmouseover="if (!this.checked) { this.checked = true; } else { this.checked = false; }" />Checkbox</label> </form>[/code] Read More

0

How about this:

<script type="text/javascript">
function checkit(formName, checkBox) {
var xx = document.formName.elements.checkBox;
xx.checked = 1;
}
</script>

<form name="myform">
  <input type="checkbox" name="mycheck" onMouseOver="checkit('myform','mycheck')" value="1"> Checking</input>
</form>
1

Or you can just simplify things by doing this:

<form name="myform27" action="#" onsubmit="return false;">
<label for="chk1">
<input type="checkbox" name"myCheck" id="chk1" onmouseover="if (!this.checked) { this.checked = true; } else { this.checked = false; }" />Checkbox</label>
</form>
Votes + Comments
Solved my problem correctly
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.