473,657 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Clear textarea onclick of image

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
3 11672
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="docume nt.forms.FORMNA ME.elements.TEX TAREANAME.value =''; "

hth
--
Ivo
Jul 23 '05 #2
"Ivo" <no@thank.you > wrote in message
news:42******** *************** @news.wanadoo.n l...
"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="docume nt.forms.FORMNA ME.elements.TEX TAREANAME.value =''; "

hth
--
Ivo


Perfect - Thanks!
Jul 23 '05 #3
"Jake" <sp******@allte l.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.ht m</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="docume nt.form1.area.v alue=''">
</form>

</body>
</html>

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5264
by: Simon | last post by:
I have another question.. Let's take a textarea with the parameter: "rows=4" (<textarea rows=4 onkeydown="CheckScrollbar()"> ) If you start typing the scrollbar at the right is not active. Only when you exceed the four lines (rows=4) the scrollbar becomes active. That moment..the moment the scrollbar becomes active..can javascript recognize/capture this moment? Thanks, Simon
7
30325
by: Paul Gorodyansky | last post by:
Hi, Say I have a text in my TEXTAREA box - 01234567890 I want - using script - insert say "abc" in the middle. Works almost OK in Internet Explorer (with one problem) based on their example at http://msdn.microsoft.com/library/en-us/dnwebteam/html/webteam12032001.asp in the chapter "O Cursor, Where Art Thou".
2
9655
by: danielboendergaard | last post by:
Hey Im making a homepage in php. I use a html form to put data into mysql and i want to make some buttons which inserts user input values into a textarea. I have used a button like this: <input type="button" value="Add Quote" onclick="document.getElementById('nyhed').value+=''"> The button works fine and insterts into the textarea. Although I want to make a button which onclick asks the user for a
3
2104
by: LoliPopas | last post by:
I'm stupid in Javascripting, but i making php forum with BBcode. and i need help with this: <head> <script> function formatSelected(from_obj, formatting, format2) { from_obj.focus (); var w = self.document.selection.createRange (); w.text = ""+w.text+""; }
3
5634
by: FunkHouse9 | last post by:
I'm working on a form to collect data in a textarea which and am trying to keep returns and spaces. I have a couple of functions that I Frankensteined together to replace returns with <br> and to replace spaces with &nbsp;. The <br> part works well enough, but I keep getting "%20" instead of "&nbsp;" for the spaces. I understand that escape() changes " " to "%20", but I would think the ConvertSpaces function below would change the %20 to...
5
5784
by: plumba | last post by:
Ok, another query.... I have a checkbox at the bottom of my form which when checked unhides a <div> block which displays the submit button. The problem I have is when the clear form button is pressed it removes the check but does not re-hide the submit <div> bit. The way i see it, I have 3 options: 1) To simply remove the clear for button. 2) To exclude the said checkbox from the CLEAR button function. 3) To have the CLEAR button run...
3
1835
by: Breana | last post by:
Ok, i have made 4 buttons, little buttons called. B =Bold, --- =Line, U = Underline, SFT = Space just above my textarea About Me. <tr> <td><input type="button" name="Button" value="B" onclick="ChangeText(this.form.aboutme, );" />&nbsp;<input type="button" name="Button" value="U" onclick="ChangeText(this.form.aboutme, ;" />&nbsp; <input type="button" name="Button" value="LINE" onclick="ChangeText(this.form.aboutme, ;"...
8
2511
by: Sandy Tipper | last post by:
I have never had a textarea content change, in any browser. On several different projects. With javascript enabled (other stuff works.) I have read lots, and everyone says it should work. Can anyone tell my what's wrong with the following code? (I was trying to create a simple demo example. The alerts are there just to help find out where it fails. The onClick isn't even getting executed, even though I get it to work elsewhere.) ------...
2
3781
by: olddocks | last post by:
i am planning on kind of editor by replacing the textarea with iframe so that i could edit the content with rich html. I am facing weird problem and i cannot set the value of iframe innerHTML with the value of textarea while loading. The idea is hide the textarea after moving the value to iframe rich text editor. what could be the problem. here is the code var myeditor;
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.