matreece
asked on
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"> Submit your 24 words here...</textarea>
Can anyone show me how its done please?
<textarea name="words24" id="words24" rows="6" cols="40" tabindex="7"> Submit your 24 words here...</textarea>
<textarea name="words24" id="words24" rows="6" cols="40" tabindex="7" onclick="javascript:this.v alue='';"> Subm it your 24 words here...</textarea>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi matreece,
<textarea name="words24" id="words24" rows="6" cols="40" tabindex="7" onclick="this.value=''">&n bsp;Submit your 24 words here...</textarea>
Wimthepimscake
<textarea name="words24" id="words24" rows="6" cols="40" tabindex="7" onclick="this.value=''">&n
Wimthepimscake
ASKER
Cheers guys for all of your quick responses.
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=''">&n bsp;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('alread yWritten') ==0) this.value='';" onchange="this.setAttribut e('already Written',1 );" alreadyWritten="0"> S ubmit your 24 words here...</textarea>
hope it helps
alambres
<textarea name="words24" id="words24" rows="6" cols="40" tabindex="7" onfocus="this.value=''">&n
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('alread
hope it helps
alambres
ASKER
Didn't think of that - thats a lot better.
Many thanks.
Many thanks.
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:Text Box>
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='';"/>
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:Text
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='';"/>