473,326 Members | 2,111 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,326 software developers and data experts.

selectStart, selectEnd undefined?

PJ6
I'd like to be able to control the text selection in an input of type text,
but JavaScript tells me that selectStart and selectEnd are undefined. Since
these properties are referenced in many JavaScript examples I must be doing
something wrong. Can anyone clue me in?

TIA,
Paul
Dec 3 '05 #1
3 3517
PJ6
Never mind, I got it. Here is an example for anyone who searches for the
answer here later...
(txt is input of type text)

var oRange = txt.createTextRange();
oRange.moveStart("character", 0);
oRange.moveEnd("character", txt.value.length);
oRange.select();
txt.focus();

Paul

"PJ6" <no****@nowhere.net> wrote in message
news:rPkkf.6254$SY.3601@trnddc06...
I'd like to be able to control the text selection in an input of type
text, but JavaScript tells me that selectStart and selectEnd are
undefined. Since these properties are referenced in many JavaScript
examples I must be doing something wrong. Can anyone clue me in?

TIA,
Paul

Dec 3 '05 #2


PJ6 wrote:
I'd like to be able to control the text selection in an input of type text,
but JavaScript tells me that selectStart and selectEnd are undefined. Since
these properties are referenced in many JavaScript examples I must be doing
something wrong.


Maybe you are looking for the properties named
selectionStart
selectionEnd
that Mozilla exposes on text controls (input controls since 1.0 I think,
textarea controls since 1.4). Opera 8 by now also exposes those properties.

The properties are readonly, if you want to change the selection use the
method
setSelectionRange(newStartPosition, newEndPosition)
of text controls exposed in those browsers.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 3 '05 #3
On 2005-12-03, PJ6 <no****@nowhere.net> wrote:
I'd like to be able to control the text selection in an input of type text,
but JavaScript tells me that selectStart and selectEnd are undefined. Since
these properties are referenced in many JavaScript examples I must be doing
something wrong. Can anyone clue me in?


You're not using Internet Explorer. Personally I wouldn't call that
"something wrong", but the select... properities are IE only.

Bye.
Jasen
Dec 4 '05 #4

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

Similar topics

2
by: RU | last post by:
Hi, I am working on a porting project to port C/C++ application from unixware C++, AT&T Standard components to g++ with STL on Linux. This application has been working properly on...
1
by: Stu | last post by:
I am trying to build the xerces shared library with 2.3.0 version of their source code on an AIX 5.1 32 bit machine with the following version of the g++ compiler /usr/local/bin/g++ -v Reading...
4
by: Mike | last post by:
I am having a problem when a field is spaces being undefined. I wasn't sure if the problem was Excel or Javascript, so I thought I would post here first. The users are able to select from a drop...
1
by: Codemutant | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** I just cannot find what is undefined in this code.
1
by: Foolster41 | last post by:
I'm rather new to C++ programing. I'm using the dev-C++ program on a windows XP OS. I'm trying to compile the code for a multi user dungeon (MUD) called circle-mud. When I compile I get the...
13
by: Don Vaillancourt | last post by:
What's going on with Javascript. At the beginning there was the "undefined" value which represented an object which really didn't exist then came the null keyword. But yesterday I stumbled...
49
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On...
3
by: Michael Sgier | last post by:
Hi i get thousands of messages like below. How shall i resolve that? Thanks Mcihael Release/src/Utility/RawImage.o: In function `CMaskImage::CMaskImage(int, int, char const*)':...
45
by: VK | last post by:
(see the post by ASM in the original thread; can be seen at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b> as an option) As that is not in relevance to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.