By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,619 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

focus on checkbox

P: n/a
Adi
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).
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"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>
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.