Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > How to select text in textbox

Reply
Thread Tools

How to select text in textbox

 
 
tshad
Guest
Posts: n/a
 
      01-18-2005
I am already giving focus to my textbox using:

<body onload="document.forms[0].firstName.focus();">

Is there a way to select all the text, if there is any?

Thanks,

Tom.


 
Reply With Quote
 
 
 
 
Leif K-Brooks
Guest
Posts: n/a
 
      01-18-2005
tshad wrote:
> I am already giving focus to my textbox using:
>
> <body onload="document.forms[0].firstName.focus();">
>
> Is there a way to select all the text, if there is any?


Stop wanting that. If a user with a slow connection visits your site,
they may start typing in the box before the page has fully loaded; then,
when it's done loading, the text they've already typed will be selected.
If they don't notice quickly enough, they will keep typing, erasing
everything they've already written. Not very fun.
 
Reply With Quote
 
 
 
 
tshad
Guest
Posts: n/a
 
      01-18-2005
"Leif K-Brooks" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> tshad wrote:
>> I am already giving focus to my textbox using:
>>
>> <body onload="document.forms[0].firstName.focus();">
>>
>> Is there a way to select all the text, if there is any?

>
> Stop wanting that. If a user with a slow connection visits your site, they
> may start typing in the box before the page has fully loaded; then, when
> it's done loading, the text they've already typed will be selected. If
> they don't notice quickly enough, they will keep typing, erasing
> everything they've already written. Not very fun.


Good point.

Thanks,

Tom


 
Reply With Quote
 
Mitja
Guest
Posts: n/a
 
      01-18-2005
On Tue, 18 Jan 2005 15:06:01 -0500, Leif K-Brooks <(E-Mail Removed)>
wrote:

> tshad wrote:
>> I am already giving focus to my textbox using:
>> <body onload="document.forms[0].firstName.focus();">
>> Is there a way to select all the text, if there is any?


> Stop wanting that. If a user with a slow connection visits your site,
> they may start typing in the box before the page has fully loaded;


What about doing it later? Like
<textbox></textbox><script ...>selectEverythingInTheBoxAbove()</script>
or even
<textbox onfocus="this.selectAll()">

That said, I must add I don't even know if JS code for selecting the
contents exists. It very probably does, I'm just too lazy to check right
now.

--
Mitja
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox, Input (text) on turbotax... anyone know which 3rd party textbox this is??? pld888@gmail.com ASP .Net 3 02-23-2007 08:51 PM
ASP.NET textbox loses text value in composite control but Textbox subclass doesn't!? ErwinP ASP .Net Web Controls 1 08-19-2005 01:50 PM
How to select all text in textbox when it gets focus? guy ASP .Net 1 10-06-2004 09:40 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM
writing two textbox's text in one textbox agb ASP .Net Web Controls 1 08-27-2003 12:57 AM



Advertisments