onclick text disappears

I'm trying to get the below text 'Submit your 24 words here' to disappear when someone clicks in the box.
Can anyone show me how its done please?

<textarea name="words24" id="words24" rows="6" cols="40" tabindex="7">&nbsp;Submit your 24 words here...</textarea>
matreeceAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arantiusCommented:
<textarea name="words24" id="words24" rows="6" cols="40" tabindex="7" onclick="javascript:this.value='';">&nbsp;Submit your 24 words here...</textarea>
0
Saqib KhanSenior DeveloperCommented:
javaScript keyword is NOT required when you using javaScript Event.

<textarea name="words24" id="words24" rows="6" cols="40" tabindex="7" onclick="this.value=''">&nbsp;Submit your 24 words here...</textarea>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wimthepimscakeCommented:
Hi matreece,
<textarea name="words24" id="words24" rows="6" cols="40" tabindex="7" onclick="this.value=''">&nbsp;Submit your 24 words here...</textarea>

Wimthepimscake
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

matreeceAuthor Commented:
Cheers guys for all of your quick responses.
0
alambresCommented:
the user can enter the textarea by tabbing so it's better to use onfocus instead of onclick:
<textarea name="words24" id="words24" rows="6" cols="40" tabindex="7" onfocus="this.value=''">&nbsp;Submit your 24 words here...</textarea>

but you'll still have a problem : if user exits the field, and then return to it, the text he wrote will disappear so, even better:

<textarea name="words24" id="words24" rows="6" cols="40" tabindex="7" onfocus="if (this.getAttribute('alreadyWritten')==0) this.value='';" onchange="this.setAttribute('alreadyWritten',1);" alreadyWritten="0">&nbsp;Submit your 24 words here...</textarea>

hope it helps

alambres
0
matreeceAuthor Commented:
Didn't think of that - thats a lot better.
Many thanks.
0
Vignesh SugumarSharePoint ConsultantCommented:
Here is another working solution!

Asp Textbox
<asp:TextBox runat="server" id="TextBox1" style="color:#999;" value="Enter here!!!" onblur="this.value = this.value || this.defaultValue; if (this.value == this.defaultValue) this.style.color = '#999';" onfocus="if (this.value == this.defaultValue) this.style.color = '#000';if (this.value == this.defaultValue) this.value='';"></asp:TextBox>

For simple html
<input runat="server" id="TextBox2" style="color:#999;" value="Enter here!!!" onblur="this.value = this.value || this.defaultValue; if (this.value == this.defaultValue) this.style.color = '#999';" onfocus="if (this.value == this.defaultValue) this.style.color = '#000';if (this.value == this.defaultValue) this.value='';"/>

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.