aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Reset Button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Reset Button" Watch "Reset Button" New topic
Author

Reset Button

Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
I am trying to add a gif onto a HTML page which will act as a reset button for a form. i know how to make a standard reset button but don't know how to add this funtionality to a GIF, can anyone help?


Pounding at a thick stone wall won't move it, sometimes, you need to step back to see the way around.
Jane Rozen
Ranch Hand

Joined: Feb 12, 2000
Posts: 53
Did you try to use form.reset() method for your img events?
Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
How I would I write that? That is what would an example line of code look? I'm really new to javascript and havn't got a clue!!
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Angela,
I prepared a small html file which has a form, in which there are some input fields and instead of RESET button an image is taken from the current directory. When you click on that image the fields will be reset. I used JavaScript to do that. Also I purposly inclided 'spaces' inside all html tags in order to prevent this forum interpret them. So please edit them back when u use them.
regds
maha anna
<pre>
< HTML >
< HEAD >
< TITLE >Duke< /TITLE >
< /HEAD >
< BODY >
< script >
< !--<br /> function clearForm(){<br /> document.LayoutForm.reset();<br /> }<br /> //-- >
< /script >
< FORM NAME="LayoutForm" ACTION="" METHOD=POST >
< TABLE >
< TR >
< TD >< P >FirstName< /TD >
< TD >< P >< INPUT TYPE=TEXT NAME="FormsEditField1" VALUE="" SIZE=9 MAXLENGTH=10 >�< /TD >
< /TR >
< TR >
< TD >< P >Age< /TD >
< TD >< P >< INPUT TYPE=TEXT NAME="FormsEditField2" VALUE="" SIZE=9 MAXLENGTH=10 >�< /TD >
< /TR >
< TR ALIGN=CENTER >
< !-- < TD COLSPAN=2 >< P >< IMG ID="Picture1" HEIGHT=68 WIDTH=55 SRC="duke.gif" lang="javascript" onclick="clearForm()" >�< /TD > -->
< TD COLSPAN=2 >< P >< IMG HEIGHT=68 WIDTH=55 SRC="duke.gif" lang="javascript" onclick="clearForm()" > < /TD >

< /TR >
< /TABLE >
< /FORM >
< /BODY >
< /HTML >
</pre>

[This message has been edited by maha anna (edited April 15, 2000).]
Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
Thanks a lot, I'll give that a try!!!
Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
I tried it but I get an error on the page.
Thanks anyway!!
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
What error do you get? I verified . It works fine for me. When you click on the image the 2 input fields will be reset.
regds
maha anna
Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
I get a notice in the staus bar saying error on page when I click on the image. It seems to be having a problem with the line with the < IMG > tag.
I've removed the spaces and can't see anything else obvious.
Jane Rozen
Ranch Hand

Joined: Feb 12, 2000
Posts: 53

Angela, what browser you are using?
If it's Netscape, just type "javascript:" next to "Location:" sign(where you are entering URLs)and press "enter". You will see so-called Javascript console window, and it will show the exact source of your error. Try it.
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Angela,
I have edited the above file shown in my previous post. Now the 'RED' colour line has NO ID field. Try in this way. Otherwise instead of lang="javascript" try language = "javascript". The minimum fields needed for an image to show are 'src' and 'width' and 'height'. Try and change these fields as necessary. You will definitely succeed.
regds
maha anna
Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
Brilliant, it works thanks!!!
Unfortunatly all the time it took to try to sort it out meant that the reset button was removed from the page by my boss, who now regrets it cos it would have made things alot better , but deadlines to meet and all that!
Never mind at least I'll know for next time, thank you
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1836
Hi,
This is all fine for me. But I have an additional problem. I have a submit button and a reset button. I can implement the reset button as specified above. But the mouse behaves differently when it is over the submit button and when it is over the reset button. Any ideas on how to solve this will be helpful
Rahul
Neil M
Greenhorn

Joined: Jul 23, 2001
Posts: 9
Rahul,
Use an image for the submit button also:
<img src="aaa.gif" onClick="document.formName.submit();">
Prashant Deshani
Greenhorn

Joined: May 03, 2006
Posts: 5
HI,
I am not able to use the reset button as specified.
I have tried the code that is written above but it gives me the error that
object does not support this property or method.
I am using IE 6.0.
While I try to open the page in mozilla firefox 1.5.0.3 it is not giving me any error while I click the image but nothing happens i.e. it does not reset anything.

Thanks and Regards,
Prashant Deshani
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reset Button
 
Similar Threads
Question regarding FBN Use Case
Adding button to JFileChooser
How to pass certain action from struts2 mapper
How do I put an image on a canvas?
java haiku