Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 07-02-2010
Member
 
Join Date: Jul 2006
Posts: 191
How to Submit a Form Using JavaScript?

I am new to the JavaScript. I somehow managed to make a form with the HTML and in that I have not used any advanced option. Its a simple form. But the thing that I am worrying about is how to Submit a Form Using JavaScript..?? Expecting some help from you guys. Please help me as soon as possible..!!
__________________
ASUS P5VD1-X
Intel Pentium Dual Core 3.00GHz
Maxtor 160GB
Corsair 1.5GB PC3200 RAM
Nvidia Geforce 6800 GT 256mb
Phillips DVD RW
Magna 500W PSU
XION II Steel Black Gaming Case
Reply With Quote
  #2  
Old 07-02-2010
Member
 
Join Date: Mar 2008
Posts: 672
Re: How to Submit a Form Using JavaScript?

You can use the following very simple code for submitting a form using the JavaScript :
Code:
<script language ="JavaScript">

function SubmitForm()
{
document.form1.action = "page1.html";
document.form1.submit()
}

function ResetForm()
{
document.form1.reset()
}

</script>
HTML Code:
<form name="form1" action="">
<a href="javascript: SubmitForm()">Demo Test</a>
</form>
Reply With Quote
  #3  
Old 07-02-2010
Member
 
Join Date: Mar 2008
Posts: 349
Re: How to Submit a Form Using JavaScript?

Form can be submitted by submit button. If you are looking to submit form with explicit function, JavaScript can help you in submitting form with submit function. This javascript submit function can call by any event of html tag. Submit function
Code:
document.formName.submit();
Hope that you have understood this simple funda of submit button.
Reply With Quote
  #4  
Old 07-02-2010
Member
 
Join Date: Nov 2008
Posts: 996
Re: How to Submit a Form Using JavaScript?

I am providing you with the example which is little big, but you can understand it very properly. Here is the code :
HTML Code:
<html>
<head>
<title>JavaScript-Submitting Form</title>
<script>
function goSubmit()
{
  document.frm.submit();
}
</script>
</head>

<body>
<form name="frm">
 <a href="javascript:goSubmit()">Submit form </a>
 <br>
 <input type="button" name="button" value="Submit" onClick="goSubmit()">
</form>
</body>
</html>
Reply With Quote
  #5  
Old 07-02-2010
Member
 
Join Date: Aug 2006
Posts: 235
Re: How to Submit a Form Using JavaScript?

The important thing you will keep in mind is that you will have to give an id attribute in the form tag. You can do this like the following :
Code:
<form id='myform' action='formtrial.pl'>
And the following is the code to submit a form when a hyperlink is clicked :
Code:
<form name="myform" action="handle-data.php">
Search: <input type='text' name='question' />
<a href="javascript: submitform()">Search</a>
</form>
<script type="text/javascript">
function submitform()
{
  document.myform.submit();
}
</script>
__________________
3.2 (northwood)
2gig ram
ATI AIW X800xt 256mb
Gigabyte GA-8knxp 875p Chipset
Optiwrite 8X DVD Burner
Win XP PRO Sp2 (Works Perfectly)
2 SATA Raptor 74gig Raid 0
2 7200 IDE 320gig HD
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to Submit a Form Using JavaScript?"
Thread Thread Starter Forum Replies Last Post
Problem of html form with multiple submit buttons ASHER Software Development 4 20-10-2009 05:31 PM
How to submit form without "Submit Button"? AK_Chopra Software Development 3 10-09-2009 08:44 AM
Frontpage form submit return 404 Not Found error dalsandhu Technology & Internet 3 06-07-2009 03:37 PM
Several submit buttons in the same form ? Wiro Software Development 5 14-02-2009 10:29 PM
Problem Submit Form in Firefox [javascript] Swetlano Software Development 0 09-02-2009 11:07 PM


All times are GMT +5.5. The time now is 05:13 AM.