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;

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

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

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

How about this:

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

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

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>
commented: Solved my problem correctly +1

Thanks guys, you two solved my whole problem!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.