focus on checkbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adi

    focus on checkbox

    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).
  • McKirahan

    #2
    Re: focus on checkbox

    "Adi" <adi.hamami@amd ocs.com> wrote in message
    news:d5f0c229.0 412220347.26c54 1ee@posting.goo gle.com...[color=blue]
    > 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).[/color]

    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.backgrou ndColor = "";
    if (form.elements[i].name == ("box"+j)) {
    form.elements[i].style.backgrou ndColor = "yellow";
    setTimeout("box blurs(" + i + ")",2000);
    }
    }
    }
    }
    function boxblurs(i) {
    var form = document.forms[0];
    form.elements[i].style.backgrou ndColor = "";
    }
    </script>
    </head>
    <body onload="documen t.forms[0].box1.focus()">
    <form>
    <input type="text" name="txt1">
    <input type="checkbox" name="box1" onfocus="boxfoc us(1)">
    <input type="checkbox" name="box2" onfocus="boxfoc us(2)">
    <input type="checkbox" name="box3" onfocus="boxfoc us(3)">
    <input type="text" name="txt2">
    </form>
    </body>
    </html>


    Comment

    Working...