/    Sign up×
Community /Pin to ProfileBookmark

Scrolling down an textarea

Hi everybody,

I have some piece of code writing down text into a textarea in reponse to a select.onchange.

Then I give focus to the target textarea.

I would like to scroll down the textarea so that cursor gets visible et blinks at the end of the textarea.

Any clue would be much appreciated.

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@Warren86Mar 04.2005 — Cursor to end of text in a textarea, on focus:

<HTML>

<Head>

<Script Language=JavaScript>

function cursorEOT(isField){

isRange = isField.createTextRange();
isRange.move('textedit');
isRange.select();
}


</Script>

</Head>

<Body>

<Form name='Form1'>

<textarea rows='6' cols='30' name='textArea1' onfocus="cursorEOT(this)">The rain in Spain falls mainly on the plain, and the quick brown fox jumps over the lazy dog's back.</textarea>

</Form>

</Body>

</HTML>
Copy linkTweet thisAlerts:
@UltimaterMar 04.2005 — hi all!

hi Warren86!

How would you go about making the cursor start at the

second character instead of the last?
Copy linkTweet thisAlerts:
@Warren86Mar 04.2005 — Ultimater:

To my knowledge, that can't be done. Second "word," yes, but not second character.
Copy linkTweet thisAlerts:
@UltimaterMar 04.2005 — How would you do it for the second word?
Copy linkTweet thisAlerts:
@Warren86Mar 04.2005 — <HTML>

<Head>

<Script Language=JavaScript>

function cursorEOT(isField){

isRange = isField.createTextRange();
isRange.move("word", 2);
isRange.select();
}


</Script>

</Head>

<Body>

<Form name='Form1'>

<textarea rows='6' cols='30' name='textArea1' onfocus="cursorEOT(this)">The rain in Spain falls mainly on the plain, and the quick brown fox jumps over the lazy dog's back.</textarea>

</Form>

</Body>

</HTML>
Copy linkTweet thisAlerts:
@UltimaterMar 04.2005 — TY warren86!

*Laughs real hard*
<i>
</i>&lt;HTML&gt;
&lt;Head&gt;
&lt;Script Language=JavaScript&gt;

function cursorEOT(isField){

isRange = isField.createTextRange();
isRange.move("[color=red]character[/color]", 2);
isRange.select();
}

&lt;/Script&gt;
&lt;/Head&gt;
&lt;Body&gt;
&lt;Form name='Form1'&gt;
&lt;textarea rows='6' cols='30' name='textArea1' onfocus="cursorEOT(this)"&gt;The rain in Spain falls mainly on the plain, and the quick brown fox jumps over the lazy dog's back.&lt;/textarea&gt;
&lt;/Form&gt;
&lt;/Body&gt;
&lt;/HTML&gt;
Copy linkTweet thisAlerts:
@ccoderMar 04.2005 — To start at the 2nd word:
<i>
</i> function EOW(isField)
{
var range = isField.createTextRange();

<i> </i> range.move("word", 2);
<i> </i> range.select();
<i> </i>}


Edit:

Oops, that places the cursor AFTER the 2nd word. I did a copy & paste and forgot to change the 2 to a 1.
Copy linkTweet thisAlerts:
@UltimaterMar 04.2005 — Thanks for contributing ccoder!
Copy linkTweet thisAlerts:
@ccoderMar 04.2005 — [i]Originally posted by Ultimater [/i]

[B]Thanks for contributing ccoder! [/B][/QUOTE]

I was a tad late with my reply.

I should add that the first parameter for .move can be character, word, sentence or textedit. If the second parameter is omitted, it defaults to 1.
Copy linkTweet thisAlerts:
@Warren86Mar 04.2005 — .
Copy linkTweet thisAlerts:
@UltimaterMar 04.2005 — I really didn't know, I just found it logical

to replace "word" with "character" and got lucky.

Besides, you did help me a lot! Thanks again!

I just found it absolutely hilarious when I ran

your code and two seconds later I did the impossible!

I'm still awestruck. I mean you no disrespect, that's the

last thing that I intent for you.
Copy linkTweet thisAlerts:
@MyttOauthorMar 04.2005 — Thanks to all of you for your answers!

Unfortunately it look like some portions of this code is not compliant with all browsers ? especially with Gecko-ased user agents

Is there a way to make it web standard compliant?

More generally, where couls I find a standard compliant javascript reference?

Anyway ,thanks a lot to all of you guys
×

Success!

Help @MyttO spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...