Jump to content

<textarea></textarea>


Johnmitchell

Recommended Posts

i have following code:

<textarea rows="10" cols="30" ID="Textarea1" NAME="Textarea1">Type the text here</textarea>

my question is, when a user clicks on the text area, how do i get the text to dissapear?

Link to comment
Share on other sites

That will work, but it will always delete the text whenever they click on it (even if they just typed their life story). So, a little more robust function may be necessary:

function clear_textarea1 (){  if (document.getElementById("Textarea1").innerHTML = "Type the text here")	document.getElementById("Textarea1").innerHTML = "";}...<textarea rows="10" cols="30" ID="Textarea1" NAME="Textarea1" onclick="clear_textarea1();">

Link to comment
Share on other sites

Dont you need to use an onblur function, here is the code that I use:

<TEXTAREA NAME="Your Name" ROWS="Height in rows" COLS="Width in columns (letters)" style="font-family: arial;" onfocus="if (this.value=='Your text here, dont use apostrophies, as it won't work, unless you use the character code') {this.value='';}" onblur="if (this.value=='') {this.value='Same again, your text here, dont use apostrophies, as it won't work, unless you use the character code';}">Same again, your text here, dont use apostrophies, as it won't work, unless you use the character code.</TEXTAREA>
I have highlighted all the bits you need to change, in bold, so when you click the box the text will disapperar, but when you click back it appears again. Just a warning , dont use appostrophies, as it messes up the code, use the character code instead.
Link to comment
Share on other sites

But I was certain justsomeguys suggestion didn't add the text back when you clicked off? I had put the bits you needed to change in bold, and wrote what you needed to put.Oh well, nevermind, im sure you will use whatever is best for you, we all do what we think is right, and so i really don't mind.

Link to comment
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
×
×
  • Create New...