faqts : Computers : Programming : Languages : JavaScript : Forms

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

26 of 35 people (74%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How can I use onclick with an image to submit a form?

Dec 12th, 2001 17:04
JustSomeDude, Arsen Yeremin,


<html>
<head>
	<title>Submit with Image</title>
</head>
<body>
<form name="my_pet" action="save.xyz">
  <input type="text" name="dog" value="sparky">
</form>
<img 
src="C:\Program Files\Common Files\Microsoft Shared\Grphflt\MS.JPG" 
onclick="document.my_pet.submit()"
>
<br>
or
<br>
<a href="javascript:document.my_pet.submit()">
<img src="C:\Program Files\Common Files\Microsoft 
Shared\Grphflt\MS.JPG">
</a>
</body>
</html>
---
Thanks for confirming this, I just have to add this.
This is exactly what I've been using, after looking at this, I just 
figured out that I needed to remove the existing standard button, to 
even make this work.  I removed this and everything worked fine.
<input type="submit" value="Save" />