Mahitha Kancherla

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromMahitha Kancherla
ToMe
Subjectreg cursor positioning in textarea
Date11 April 2005 11:39
hi

    i found ur site very useful.
    i have a question
     how to set the cursor position in the textarea

    i hope to  get a response from u

thanks & regards
mahitha
FromMe
ToMahitha Kancherla
SubjectRe: reg cursor positioning in textarea
Date11 April 2005 17:08
Mahitha,

> how to set the cursor position in the textarea

function setCursorPosition(oInput,oStart,oEnd) {
    oInput.focus();
    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();
    }
}

Now you can do this to put the cursor after the 5th character:
setCursorPosition(document.myform.mytextarea,5,5);
Or to select the third character:
setCursorPosition(document.myform.mytextarea,2,3);

This should work in Internet Explorer on Windows, Mozilla
1.3+/Firefox/Netscape 7+, Opera 8+. On other browsers, it will put the
cursor in the textarea, but will not be able to position it correctly.

[Ed. this also works in Safari 1.2+, and Konqueror 3.5.2+]

Note the difference between different platforms. If your textarea
contains linebreaks, these linebreaks should be a single character on
mac and linux/unix, and two characters on Windows.


Hope this is what you needed.

Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromMahitha Kancherla
ToMe
SubjectRe: reg cursor positioning in textarea
Date12 April 2005 06:47
Thank you Jones for a quick response.

[Ed. Jones? Jones?! Foo! :P ]

Regards
Mahitha K.
FromMahitha Kancherla
ToMe
Subjectroundrect tabs
Date13 April 2005 11:07
Hi ,

I want roundrect tabs in css.Can u plz help me in this.

Thank you.
FromMe
ToMahitha Kancherla
SubjectRe: roundrect tabs
Date13 April 2005 11:46
> I want roundrect tabs in css.Can u plz help me in this.

a tutorial for this:
http://www.alistapart.com/articles/slidingdoors/
FromMahitha Kancherla
ToMe
SubjectRe: roundrect tabs
Date13 April 2005 12:42
Thank you

Mahitha K.
FromMahitha Kancherla
ToMe
Subject 
Date5 May 2005 13:20
Hi,

 I am trying to make textarea work as textbox i am discarding enter key
stroke using onkeydown event. but if i paste multiline content it is
allowing the content.
So i want to know
      -how to disable paste operation in textarea ? or
      -how to restrict paste operation to paste only a single sentence not
more than 1 sentence.

Plz let me know abt this.Hope u will respond me soon.
Thank you.



Regards,
Mahitha K.
FromMe
ToMahitha Kancherla
SubjectRe: discarding line breaks in a textarea
Date5 May 2005 14:04
Mathia,

>       -how to restrict paste operation to paste only a single sentence not
> more than 1 sentence.

<textarea ... onchange="this.value=this.value.replace(/[\r\n]+/,' ');">
or some other appropriate replacement

Tarquin

PS. please include a subject when sending emails
FromMahitha Kancherla
ToMe
SubjectRe: discarding line breaks in a textarea
Date5 May 2005 15:30
Tarquin,

       Thank you  very much for ur quick response.
        I have another issue
          We have reports that take lot of time
          Once the user clicks a report link We are starting a seperate
          thread for report execution
          and showing a loading page which refreshes every 15 secs to check
          the report status

     <script>
          setTimeout("callit()",15000);
      function callit()
      {
          location.replace('checkStatus.do?requestedReportKey=12344');
      }
     </script>

     This is working perfect for normal html reports, in the sense that
after getting the report if i click back button i donot see the loading
page as i am replacing
     but when we download the report as excel sheet its not affecting ie
back button still shows me the loading page.
I hope u will help me for this issue also.

Thank you Tarquin.
FromMe
ToMahitha Kancherla
SubjectRe: discarding line breaks in a textarea
Date5 May 2005 23:09
Mahitha,

>      but when we download the report as excel sheet its not affecting ie
> back button still shows me the loading page.

That is because the excel spreadsheet is not loaded natively by the browser,
so the history entry is discarded, reverting back to the loading page. I do
not know any way to avoid this issue.

Tarquin
FromMahitha Kancherla
ToMe
SubjectReg onkeypress
Date18 May 2005 15:44
Hi Tarquin ,

How r u?
My problem is when i enter some text in textbox and press enter key then
same page should open.
I am using this.<INPUT name=title size=70 value="title"
onkeypress=history.go(0);>
.Its working but  not allowing me to edit the text in text box.

Plz reply me.

Thank you.


Regards,
Mahitha K.
FromMe
ToMahitha Kancherla
SubjectRe: discarding line breaks in a textarea
Date18 May 2005 20:35
> I am using this.<INPUT name=title size=70 value="title"
> onkeypress=history.go(0);>


You need to check what key is being pressed, and bypass all the browser
incompatibilities. I suggest you read my event information page:
http://www.howtocreate.co.uk/tutorials/javascript/eventinfo

function checkKey(e) {
    if(!e) { e = window.event; } if(!e) { return; }
    if( typeof( e.which ) == 'number' ) {
        e = e.which;
    } else if( typeof( e.keyCode ) == 'number'  ) {
        e = e.keyCode;
    } else if( typeof( e.charCode ) == 'number'  ) {
        e = e.charCode;
    }
    if( e == 13 ) { history.go(0); }
}

<INPUT name=title size=70 value="title" onkeypress="checkKey(arguments[0]);">
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.