set focus

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • java
    New Member
    • Oct 2006
    • 10

    set focus

    hi,

    i am facing the probelm to set the cursor at my current field after the alert message box pop out. The cursor is set to next field after i click ok button at the warning msg box

    if(amtlength <= 3 ){
    alert ("Amount should greater than 1000");
    document.form12 3.myid.focus();
    }

    any idea?

    thx..
  • Thevercad
    New Member
    • Oct 2006
    • 26

    #2
    hi,

    the following is what i did.. i dont know if this is how you want it to work.

    Code:
    <html>
        <head>
            <script language="Javascript">
                function clickFunct(){
                    alert('this is an alert');
                    document.getElementById('Text1').focus();
                }
            </script>
        </head>
        <body>
            <form>
                <a href="#" onClick="clickFunct();">Click Me</a>
                <input id="Text1" name="Text1" type="text" value="its a text" />
            </form>
        </body>
    </html>
    in this case, i have used the ID option to set the focus. If thats fine by you, then this code will work.

    Comment

    • vssp
      Contributor
      • Jul 2006
      • 268

      #3
      use document.getEle mentById('Text1 ').focus();

      vssp

      Comment

      • java
        New Member
        • Oct 2006
        • 10

        #4
        thanks all..

        Comment

        Working...