...

View Full Version : Submit form with anchor tag



colindunn
07-04-2007, 07:21 PM
I am trying to submit a form using an anchor tag and without javascript. I am not entirely certain this can be done and would use javascript as a fall back. Any help would be appreciated.

Edit:
I found this bit of code that is suppose to do the trick. Still looking for a non-javascript solution.


<form name="theForm">
<input type=text name="formInput">
<a href="javascript:document.theForm.submit();">Submit</a>
</form>

Jutlander
07-04-2007, 07:48 PM
You will need a script to submit a form. It cannot be done with just HTML.

koyama
07-05-2007, 12:25 AM
In Firefox it is possible to style an input[type="submit"] element using CSS so it looks exactly like an ordinary link. This involves removing the background color, changing the font, removing the border and padding.

In IE7 and IE6 you can also style the input[type="submit"], but it seems that you cannot get rid of the padding. At least I don't know how. For this reason the pure CSS approach cannot be used.

The best solution may be to use the input[type="submit"] element and then use JavaScript to replace it with e.g. a span element that can better be styled. Doing it in this way means that your page will still be functioning when JavaScript is disabled in which case one gets the ordinary submit button.

colindunn
07-05-2007, 01:41 AM
Well my purpose was not to submit a form via text link but rather to use an image and the background-position property for hover and active states. Thanks for your help anyway, it seems that what I am asking for cannot be done.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum