Results 1 to 5 of 5

Thread: How to Submit a Form Using JavaScript?

  1. #1
    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

  2. #2
    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>

  3. #3
    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.

  4. #4
    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>

  5. #5
    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

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,273,598.82802 seconds with 16 queries