Jump to content
xisto Community
Sign in to follow this  
Amezis

Select All Text In A Form Field On Click

Recommended Posts

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; ?>]">
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...

Share this post


Link to post
Share on other sites

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; ?>]" onClick='highlight(this);'>

Hope that helps. :huh:

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.