Thursday, March 22, 2012

Submit a form with a link

Here's a way to use a link for submitting a form.

The form

The form is created as usually, except for that it needs an id attribute and the submit button is not necessary.

<form action="script.php" method="post" id="simple_form">
   <input type="text" name="some_info" value="" />

The link

The link has a href attribute pointing to nowhere (void() is a built-in JavaScript function that does nothing), and an onclick code that submits the form when the link is clicked.

<a href="javascript:void(0);"

No comments:

Post a Comment