jQuery and ASP.NET

April 6, 2009

Submit a HTML Form using a Hyperlink




A user asked me recently on the forums if it was possible to Submit an HTML form without the Submit button. She wanted to do it using a Hyperlink instead.

Well it is possible to submit the form using a hyperlink with a small amount of JavaScript code as shown here:

<html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Submit A HTML Form using a Hyperlink</title>

<
script type="text/javascript">
function
frmSubmit() {
document.form1.submit();
}
</script>
</
head>

<
body>
<
form name="form1" method="post" action="somescript.pl" >
<
div>
<
a href="javascript:frmSubmit();">Submit</a>
</
div>
</
form>
</
body>
That’s all you need!

'Like' us on our FaceBook page if you find this blog useful. Thanks!


Did you like this post?
kick it on DotNetKicks.com Save on Delicious
subscribe via rss subscribe via e-mail
print this post follow me on twitter


About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

comments

1 Response to "Submit a HTML Form using a Hyperlink"
  1. fixy32 said...
    April 7, 2009 7:20 AM

    I was trying it out on ASP.NET form and face error

 

Copyright © 2009-2011 All Rights Reserved for DevCurry.com by Suprotim Agarwal | Terms and Conditions