"Adi" <ad********@amdocs.com> wrote in message
news:d5**************************@posting.google.c om...
I'm trying to do default focus on checkbox,its work fine but the
problem is that the user cannot know where is the focus (there isn't
visual sign and on the other hand if you press on the tab button there
is a visual sign).
Here's one approach. Watch for word-wrap.
This changes the background color (to yellow) of the checkbox that has focus
for two seconds.
<html>
<head>
<title>boxfocus.htm</title>
<script type="text/javascript">
function boxfocus(j) {
var form = document.forms[0];
for (var i=0; i<form.elements.length; i++) {
if (form.elements[i].type == "checkbox") {
form.elements[i].style.backgroundColor = "";
if (form.elements[i].name == ("box"+j)) {
form.elements[i].style.backgroundColor = "yellow";
setTimeout("boxblurs(" + i + ")",2000);
}
}
}
}
function boxblurs(i) {
var form = document.forms[0];
form.elements[i].style.backgroundColor = "";
}
</script>
</head>
<body onload="document.forms[0].box1.focus()">
<form>
<input type="text" name="txt1">
<input type="checkbox" name="box1" onfocus="boxfocus(1)">
<input type="checkbox" name="box2" onfocus="boxfocus(2)">
<input type="checkbox" name="box3" onfocus="boxfocus(3)">
<input type="text" name="txt2">
</form>
</body>
</html>