Click to See Complete Forum and Search --> : Changing form buttons to images


DarryBoy
04-21-2003, 05:34 PM
I have replaced the two bland buttons Reset and Submit within a form with images. The submit button works the way it should but the reset button works the same as submit now.

Is there a way to solve my problem?

Kind regards
Darryn

Jona
04-21-2003, 05:38 PM
Try this:

<html><head>
<script>
function clear(){
for(x=0;x<document.formName.elements.length;x++)
document.formName.elements[x].value="";
}
</script>
</head><body>
<form name="formName">
<input type=text value="Text">
<input type=text value="More text"><br>
<input type=image src="your_submit_image.gif">
<img src="your_reset_button.gif" onClick="clear()">
</form></body></html>

DrDaMour
04-21-2003, 05:50 PM
if you're using <input type=image src="">

then do this

<input type=image src="" onclick="this.form.reset()">

Jona
04-21-2003, 05:53 PM
My bad, DrDaMour... Hehe, forgot about that. :p

But my code does work... Doesn't it? Other than the fact that it would make all of the buttons' values cleared, too! :p

DrDaMour
04-21-2003, 05:55 PM
well no, your code woudl kind of work. First the buttons would be screwed, second i thikn check boxes don't have .values actually i just looked and checkboxes .value is .type, so doign that woudl really screw up a form.

DarryBoy
04-21-2003, 06:25 PM
Thank you DrDaMour this works perfectly.

I didn't reply to your post the other day because I felt that you thought I was being obnoxious. I promise I wasn't.

Thanx mate.

DarryBoy
04-21-2003, 06:27 PM
You came to my rescue again Jona. Thank you.