Click to See Complete Forum and Search --> : image button???


snoopy0877
10-10-2003, 09:51 PM
I have a form with 3 image button at the end:

<input name="imageField" type="image" src="images/button_previous.gif" onClick="javascript:history.go(-1);">

<input name="imageField2" type="image" src="images/button_send.gif" onClick="return CheckForm(fl);">

<input name="imageField3" type="image" src="images/button_next.gif" onClick="javascript:document.location='page2.htm';">

But It's not done when I click on the Previous and the Next button. If I use "Previuos" and "Next" by <input type=button name=Previous value=Previous onClick="javascript:history.go(-1);"> <input type=button name=Next value=Next onClick="javascript:document.location='page2.htm';"> it's will done correctly.

But I want to use image button for a this "graphic form". Can you help me? Thks

gil davis
10-11-2003, 08:31 AM
The default action of the IMAGE type of INPUT tag is to SUBMIT a FORM. That is probably what is happening in your page. It might help to add "return false" to the onClick.
<input name="imageField" type="image" src="images/button_previous.gif" onClick="history.go(-1);return false">
<input name="imageField2" type="image" src="images/button_send.gif" onClick="return CheckForm(fl);">
<input name="imageField3" type="image" src="images/button_next.gif" onClick="document.location='page2.htm';return false">No guarantee expressed or implied/ Your mileage may vary.

Alternately, use an image link for the two that don't work.
<a href="#" onClick="history.go(-1);return false"><img src="images/button_previous.gif" border=0></a>
<input name="imageField2" type="image" src="images/button_send.gif" onClick="return CheckForm(fl);">
<a href="page2.htm"><img src="images/button_next.gif" border=0></a>