Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2007
    Posts
    49
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Submit form with anchor tag

    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.

    Code:
    <form name="theForm">
    <input type=text name="formInput">
    <a href="javascript:document.theForm.submit();">Submit</a>
    </form>
    Last edited by colindunn; 07-04-2007 at 08:27 PM.

  • #2
    Regular Coder Jutlander's Avatar
    Join Date
    Jun 2007
    Location
    In my own sick little world :P
    Posts
    425
    Thanks
    1
    Thanked 12 Times in 12 Posts
    You will need a script to submit a form. It cannot be done with just HTML.
    .
    .

  • #3
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    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.

  • #4
    New Coder
    Join Date
    Apr 2007
    Posts
    49
    Thanks
    10
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •