473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Position cursor at the end in textareas

Ubi
Hi guys,

I am loading a page with textareas containing text.
By the default, the cursor goes at the beginning of the text.

I would like to position the cursor at the end of the text instead.

Does anyone have a quick script to handle this?
Daniele
May 14 '07 #1
4 7120
On May 14, 8:14 am, "Ubi" <ubimm...@libero.itwrote:
I am loading a page with textareas containing text.
By the default, the cursor goes at the beginning of the text.

I would like to position the cursor at the end of the text instead.
var t=textAreaElement,
len=t.value.length;
if(t.setSelectionRange){
t.setSelectionRange(len,len)
t.focus()
}else if(t.createTextRange){
var rn=t.createTextRange();
rn.moveStart('character',len)
rn.select()
}

May 14 '07 #2
ASM
Ubi a écrit :
Hi guys,

I am loading a page with textareas containing text.
By the default, the cursor goes at the beginning of the text.
When I click in a textarea the cursor goes where I've clicked ...

If I do : myTextarea.focus();
the cursor comes at the end.

How do you do to get it in 1st position ?
I would like to position the cursor at the end of the text instead.
<body onload="document.myForm/myText.focus();">

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
May 14 '07 #3
Ubi
Thanks a lot!
May 14 '07 #4
Ubi
How do you do to get it in 1st position ?

With Firefox, it goes to the end.
With IE, it goes to the beginning.

Thanks for replying!
Daniele
May 14 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jason | last post by:
I've got this javascript routine (i found on google - thank you) in an asp.net page that on page reload sets the cursor of a textbox to the last line. It works great! Using a similar concept, I...
3
by: PeP | last post by:
Good morning, I have a form containing a text-area, I'd like to know if it exists a function that, when I activate an event, returns the position of the cursor in the text-area. For example, I...
25
by: JeffS | last post by:
Honest, I scoured the comp.lang.c.faq for this but found nothing. :) Is there a library function for placing the cursor position in the console? Or is it something that can only be done with a...
3
by: Mathieu Chavoutier | last post by:
I want to make a tool to design (like paint). So, I want to know the position of the mouse. Cursor.Position.X gives me that information. But, when I draw a picture, it is not at the good place...
1
by: Tantra Veda | last post by:
Hello C# gurus, I have a question about finding cursor position in NumericUpDown control. On my form I have a numericUpDown control with 2 decimal places. I want to increment value in the numeric...
1
by: Paul | last post by:
Hi all, I am making a DirectInput application wich must report correctly the cursor position in windowed mode (it means it has to be the same as Microsoft Window´s cursor position). First of...
2
by: tony | last post by:
Hello! Assume I catch a double click in a form by using the event handler that forms designer create for me. Now to my question when I double click in the form the event handler is trigged...
1
by: jobs | last post by:
I'm trying to understand this and don't get it... I found some code that looks like it's going to work if I can make sense of how to position the div. The code displays a div with some data...
4
by: Billy | last post by:
Hi all, I'm building a text file from a database table using the ASP Write Method and would like to position the cursor in a specific column position before writing the fields. As I loop through...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.