By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,773 Members | 1,330 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,773 IT Pros & Developers. It's quick & easy.

Clear textarea onclick of image

P: n/a
How can I have an image that when clicked would clear my textarea field?

The textarea field is the only element in my form and has a default value -
a couple lines of text..
I tried using a reset button but it only clears text that was just entered.

TIA!
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Ivo
"Jake" wrote
How can I have an image that when clicked would clear my textarea field?

The textarea field is the only element in my form and has a default value - a couple lines of text..
I tried using a reset button but it only clears text that was just

entered.

Yes, the reset() method of forms returns all input elements to their default
values. In case you supply your own default value, this is what will be
used. To empty the element you then need to explicitly forward an empty
string, such as the pair of single quotes in the following:

<img src="..." width="..." height="..." alt=" Clear the textarea! "
onclick="document.forms.FORMNAME.elements.TEXTAREA NAME.value=''; "

hth
--
Ivo
Jul 23 '05 #2

P: n/a
"Ivo" <no@thank.you> wrote in message
news:42***********************@news.wanadoo.nl...
"Jake" wrote
How can I have an image that when clicked would clear my textarea field?

The textarea field is the only element in my form and has a default

value -
a couple lines of text..
I tried using a reset button but it only clears text that was just

entered.

Yes, the reset() method of forms returns all input elements to their
default
values. In case you supply your own default value, this is what will be
used. To empty the element you then need to explicitly forward an empty
string, such as the pair of single quotes in the following:

<img src="..." width="..." height="..." alt=" Clear the textarea! "
onclick="document.forms.FORMNAME.elements.TEXTAREA NAME.value=''; "

hth
--
Ivo


Perfect - Thanks!
Jul 23 '05 #3

P: n/a
"Jake" <sp******@alltel.net> wrote in message
news:e1***************************@ALLTEL.NET...
How can I have an image that when clicked would clear my textarea field?

The textarea field is the only element in my form and has a default value - a couple lines of text..
I tried using a reset button but it only clears text that was just entered.
TIA!


If you want to stay with buttons:

<html>
<head>
<title>clear.htm</title>
</head>
<body>

<form name="form1">
<textarea name="area" cols="40" rows="4">Hello World</textarea>
<br><br>
<input type="reset" value="Reset">
<input type="button" value="Clear" onclick="document.form1.area.value=''">
</form>

</body>
</html>

Note that
.value=''"
is typed as
".value=" + apostrophe + apostrophe + quotation mark
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.