Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Select All Text In A Form Field On Click


4 replies to this topic

#1 Amezis

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 535 posts
  • Location:Oslo, Norway

Posted 03 October 2005 - 10:51 AM

Hi, I have made a script which generates a BBcode when you run it, and displays it in a text field, like this:
<input type="text" name="bbcode" size="81" value="[IMG]<?php echo $url; ?>[/IMG]">
Well, anyway, I want something that selects all the text in that form field when you click on it, like it does in ImageShack when you upload...

#2 Avalon

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 630 posts
  • Location:Melbourne, Australia

Posted 03 October 2005 - 12:26 PM

Looking at the Imageshack site, this is the way you could do it for your site.

Set up a function in between the <head> </head> tags of your page like this.
<script language="JavaScript">
	function highlight(field) {
        field.focus();
        field.select();
}</script>

And then for each field that you want to select all the text in when clicked, add this 'onClick' action.

<input type="text" name="bbcode" size="81" value="[IMG]<?php echo $url; ?>[/IMG]" onClick='highlight(this);'>

Hope that helps. :huh:

#3 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 28 July 2009 - 11:19 PM

These instructions arenSelect All Text In A Form Field On Click

Hello,

 I tried following the instructions you provided to create a textarea with one-click-select-all  behavior in a wordpress article.  I had to include the 

function highlight(field) {        field.Focus();        field.Select();}

in an external file.  When trying to use the highlight(), nothing happens.  Any update to this script?

-reply by gnucom

#4 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 23 February 2010 - 01:39 PM

These instructions aren Select All Text In A Form Field On Click

function highlight(field) {        field.Focus();        field.Select();}

javascript  is case sensitive...

Should

field.Focus();  Field.Select();

you could  just add to onclick this.Select()

 

 

-reply by philt

#5 master99

    Newbie

  • Kontributors
  • Pip
  • 5 posts

Posted 06 May 2010 - 08:13 AM

See this link to get the answer
http://www.tutorials99.com




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users