Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How do I know the whole text of an INPUT element is selected

Reply
Thread Tools

How do I know the whole text of an INPUT element is selected

 
 
datactrl
Guest
Posts: n/a
 
      06-07-2004
Hi, all

How do I know the whole text of an INPUT element is selected?

Jack


 
Reply With Quote
 
 
 
 
Ivo
Guest
Posts: n/a
 
      06-07-2004
"datactrl" wrote
> How do I know the whole text of an INPUT element is selected?
>


<script>
function isselect(){
if (document.getSelection)
return document.getSelection(); // if NS
if (document.selection && document.selection.createRange)
return document.selection.createRange().text; // if IE4+
return false;
}
function test(){
var a=document.forms[0].elements['thetext'].value;
var b=isselect();
if(a==b) alert('Selected all!');
else if(b) alert('Selected:\n'+b);
else alert('Naught selected.');
}
</script>
<form>
<input type="text" name="thetext" value="select me">
<input type="button" value="Click me" onmousedown="test()">
</form>

HTH
Ivo



 
Reply With Quote
 
 
 
 
datactrl
Guest
Posts: n/a
 
      06-08-2004
Thanks Ivo, it's a good help.

Jack


 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
*WITHOUT* using: ValidateRequest="False" for the whole page (or my whole site).... \A_Michigan_User\ ASP .Net 2 08-21-2006 02:13 PM
Not only the selected HREF gets surrounded, but the whole row gets surrounded Stefan Mueller HTML 5 07-10-2006 11:53 AM
How to know which element was selected in a repeater? Hans Merkl ASP .Net 1 12-12-2005 01:46 AM



Advertisments