Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1119 Can I use an image in place of a button to submit a form? If so, how can I validate which image was selected?

You are here: irt.org | FAQ | JavaScript | Image | Q1119 [ previous next ]

The function you need is document.myForm.submit() It can be called form any event handler - a link is ok:

<form name="myForm">
<input name="whatImage" type="hidden">
</form>

<a href="javascript:document.myForm.whatImage='image1';document.myForm.submit()"><img src="image1.gif"></a>
<a href="javascript:document.myForm.whatImage='image2';document.myForm.submit()"><img src="image2.gif"></a>

Feedback on 'Q1119 Can I use an image in place of a button to submit a form? If so, how can I validate which image was selected?'

©2018 Martin Webb