?
Solved

onclick text disappears

Posted on 2004-12-01
7
Medium Priority
?
4,151 Views
Last Modified: 2010-05-18
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>
0
Comment
Question by:matreece
7 Comments
 
LVL 18

Expert Comment

by:arantius
ID: 12717584
<textarea name="words24" id="words24" rows="6" cols="40" tabindex="7" onclick="javascript:this.value='';">&nbsp;Submit your 24 words here...</textarea>
0
 
LVL 23

Accepted Solution

by:
Saqib Khan earned 200 total points
ID: 12717597
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
 
LVL 6

Expert Comment

by:wimthepimscake
ID: 12717625
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:matreece
ID: 12717776
Cheers guys for all of your quick responses.
0
 
LVL 5

Expert Comment

by:alambres
ID: 12717849
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
 

Author Comment

by:matreece
ID: 12736384
Didn't think of that - thats a lot better.
Many thanks.
0
 

Expert Comment

by:Vignesh Sugumar
ID: 22769579
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question