Results 1 to 6 of 6

Thread: HTML Textarea AutoActive

  1. #1
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default HTML Textarea AutoActive

    Hi i am looking for way that when a user clicks this link
    Code:
    <a onclick=\"toggle('$SAM[sh_id]');parent.location='#SAM{$shouts[sh_id]}'\"><div class='reply'></div></a>";
    I would like it to auto select this text area
    Code:
        <textarea name=minishout rows=4 onKeyDown=\"textCounter(this.form.message,this.form.remLen,300);\" onKeyUp=\"textCounter(this.form.minishout,this.form.remLen,300);\" style=\"width: 100%; height:50px;\">@{$SAM[login]}</textarea>
    This is for the iPhone, i woudl basicly make it so that it allows a user to just start typing.

    Any help would be great

    Thanks
    The web in one word.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Without seeing your page, it would be difficult to supply the correct code. Here is a demo of the concept:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    function setCursorPosition(oInput,oStart,oEnd) {
       	       if( oInput.setSelectionRange ) {
        	         oInput.setSelectionRange(oStart,oEnd);
                 } 
                 else if( oInput.createTextRange ) {
                    var range = oInput.createTextRange();
                    range.collapse(true);
                    range.moveEnd('character',oEnd);
                    range.moveStart('character',oStart);
                    range.select();
                 }
           }
    window.onload = function(){
    var ta = document.forms[0].elements['bob'];
    ta.focus();
    setCursorPosition(ta, ta.value.length, ta.value.length);
    };
    </script>
    </head>
    <body>
    <form action="">
    <textarea name="bob" cols="50" rows="5">Hi</textarea>
    </form>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    thanks that works well on firefox but not on the iPhone
    The web in one word.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I have no iPhone to test on, sorry.

    It also works in IE, Opera, and Safari. It does require javascript enabled, perhaps the iPhone browser doesn't support javascript, or has only a limited subset of javascript, or your iPhone just has javascript disabled.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    interesting i tested it in Safari and did not work... all i did was copy and past
    The web in one word.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I used Safari 3 Win. What did you use? Does it have javascript enabled? I did do some checking on the web about iPhone and javascript:

    http://www.kudit.com/wiki/index.php/Javascript

    and other similar sites. The iPhone is said to be limited to a degree as regards javascript, but I found nothing concrete either way about this particular code.

    This might be especially helpful:

    http://www.kudit.com/wiki/index.php/Copy_Paste
    Last edited by jscheuer1; 06-18-2008 at 12:34 AM. Reason: add another link
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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