Log in

View Full Version : Submitting and resetting forms with links and images



codetc
02-12-2009, 05:06 AM
Hi,, I am trying to submit/reset forms using links and images from outside the <form> tag

I was using this:

<a href="#" onclick="document.getElementById('formname').submit();"> Test link for submitting form </a>
and

<a href="#" onclick="document.getElementById('formname').reset();"> Test link for reseting form </a>

but they don't seem to work. Help please.

bluewalrus
02-12-2009, 05:44 AM
Is there a reason why it has to be outside the form tagS?
With the the form it can be done quit easily with input types.

codetc
02-12-2009, 05:52 AM
Not particularly - just wanting a more uniform interface - for the form to fit in with the rest of the site.

bluewalrus
02-12-2009, 05:59 AM
Would this work?
<input type="submit" src="" />
<input type="reset" src="" />

codetc
02-12-2009, 06:10 AM
That would still be within the <form> .. </form>?

WIth src being the location of the image/link? Would that work with no <img> tag?

bluewalrus
02-12-2009, 02:28 PM
Yea. These are all (or atleast a lot) possible input attributes and what they do. http://htmlhelp.com/reference/html40/forms/input.html