-3

I want to click on below link instead of the traditional way:

E.g

 <a href="">Click Here</a> 

instead of :

<input type="submit" value="Click Here"/>

Thanks in advance

4 Answers4

1

Use

onclick="document.forms[0].submit()"

This will submit the first form in the document.

Or, if the form has name property, you can use

onclick="document.form_name.submit()"
Al.G.
  • 4,327
  • 6
  • 31
  • 56
1
<a href="javascript:document.getElementById('yourForm').submit();">Click Here</a>

And your form should have an id:

<form id="yourForm" ...>
nicael
  • 18,550
  • 13
  • 57
  • 90
0

Okay, first of all, if you have to use an a tag for submitting.

I suggest you to use jquery.

<script type="text/javascript">
    $(document).ready(function(){
        $('form > a.submitter').click(function(){
            $(this).parent().submit();
            return false;
        });
    });
</script>

But i strongly suggest you to use a button tag for submitting forms. Because buttons are easy to style.

just use:

<button type="submit">Submit</button>
Canser Yanbakan
  • 3,780
  • 3
  • 39
  • 65
-1

Something like

<a href="#" style="color:#000000;text-decoration:none;" onclick="this.form.submit();">Submit</a>

Are you using image, or something like that in the <a> element?

Jamie
  • 1,096
  • 2
  • 19
  • 38