Submit JavaScript ile formda nasıl yapılabilir

In normal cases, a form is submitted when the user presses a submit button. However, sometimes, you may need to submit the form programmatically using JavaScript.

JavaScript provides the form object that contains the submit method. Use the name of the form to get the form object.

For example, if the name of your form is 'myform', the JavaScript code for the submit call is:
[code]document.myform.submit();[/code]

But, how to name a form? Simple! Mention the name attribute in the form tag
[code]<form name='myform' action='formmail.pl'>[/code]

Suppose you want to submit a form when the user clicks on a hyperlink. The code below shows how to do it.
[code]
<form name="myform" action="handle-data.php">
Search: <input type='text' name='query'>
<A href="javascript: submitform()">Search</A>
</form>
<SCRIPT language="JavaScript">
function submitform()
{
document.myform.submit();
}
</SCRIPT> [/code]


[url=http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml]http://www.javascript-coder.com/javascr ... bmit.phtml[/url]

Konular

Hanci.org sizlere daha iyi hizmet sunmak için çerezleri kullanıyor.
Hanci.org sitesini kullanarak çerez politikamızı kabul etmiş olacaksınız.
Detaylı bilgi almak için Gizlilik ve Çerez Politikası metnimizi inceleyebilirsiniz.