Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Cursor Position

  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cursor Position

    Hi,
    I am using a textarea field in a form and the textarea box should allow only specified no. of strings or characters.
    I wrote following javascript code which will not allow the user to enter nore than specified no. of characters. The script function worksfine. But my problem is the cursor gets pointed to the initial position of the textbox when scroll bar appears, This issue is only with the firefox but works fine in IE. please help me.

    Code:
    <script language = javascript>
    function mlength(){
      var mlen  = document.sds.back.value;
      var siz = mlen.length;
      var le = <?php echo($textarea_size); ?>;
     if (siz > le)  {
       mlen = mlen.substring(0,le);
      }
    document.sds.back.value = mlen;
    siz = (le - mlen.length);
    document.sds.sizea.value = siz;
    }
    </script>
    form name is sds and field name is back.

    Regards,
    Sugan

  • #2
    Regular Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    223
    Thanks
    0
    Thanked 14 Times in 14 Posts
    I think you need to use the "innerText" property, rather than the "value" property in firefox, i.e;
    Code:
    document.sds.back.innerText

  • #3
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cursor Position

    Hi,

    Thanks a lot. It worked fine.....

    Regards,
    Sugan


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •