At the moment i have this:
<textarea name="comment" cols="55" rows="8">Please feel free to leave a comment or a question here</textarea>
I want it to go blank when the user click on it.
Can anyone help me with this?
At the moment i have this:
<textarea name="comment" cols="55" rows="8">Please feel free to leave a comment or a question here</textarea>
I want it to go blank when the user click on it.
Can anyone help me with this?
1. Textarea does not have onclick event
2. If it did, that would clear the area even when a user went back to edit the area
HTML Code:<html> <head><title>Test</title> <script type="text/javascript"> var flag = true ; function clear_me(){ if( flag ){ var t = document.getElementById( 'comm' ); t.defaultValue = '' ; flag = false; } } </script> <body> <textarea name="comment" cols="55" rows="8" id="comm" onfocus="clear_me()" ;>Please feel free to leave a comment or a question here</textarea> </body> </html>
Not your mistake, mine.
It does have an onclick event.
But the part about needing a flag to disable it after the first use is valid. Plus, onfocus works even in the case they use TAB to get to the textarea rather than by clicking.
Hmmm.....under further testing, using 'defaultValue' seems to remove the need for the flag, while 'value' does require it.
Last edited by descalzo; 05-12-2010 at 10:46 AM.
You mean something like this:Hmmm.....under further testing, using 'defaultValue' seems to remove the need for the flag, while 'value' does require it.
I have no idea if that works on text areas though.HTML Code:<textarea name="comment" cols="55" rows="8" id="comm" onfocus="if(this.value == this.defaultValue){this.value = ''}">Please feel free to leave a comment or a question here</textarea>
Thanks works fine
I have one other thing, thought I'd ask here instead of making a new thread...
How do i get the below to work?
if (document.orderform.terms.value== false) {
alert("You must agree to our terms and conditions below an order can be processed")
document.orderform.terms.focus()
return false
}
HTML:
<p>By clicking on the below you have read and agree to our terms and conditions</p>
<input type="checkbox" name="terms" /><p>I Agree</p>
I tried the below and it still doesn't work(
if (document.orderform.terms.checked== false) {
alert("You must agree to our terms and conditions below an order can be processed")
return false
}
What do you mean by DOM objects?
try:
Code:var checkBox = document.forms.orderForm.elements.terms; if(checkBox.checked == false) { // Run code }
Last edited by as4s1n; 05-13-2010 at 11:33 AM.
There is no such thing as a "stupid question," there are only "stupid people" who don't ask them.