Web Analytics Made Easy -
StatCounter how to submit a form via javascript - CodingForum

Announcement

Collapse
No announcement yet.

how to submit a form via javascript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to submit a form via javascript

    I have a button (type button) in a form, which when clicked calls a javascript function. For the moment all I need that function to do is submit the form - i thought it was submit(); but i get an error saying object expected - am i missing something obvious here?

  • #2
    Why not just use it as type=submit for the time being rather than type=button. You said thats the only reason you have it up to now, so stick with what you can. Further on, then you acn add more functionality but stick to the above mentioned for now.
    Matt Sartain
    Internet Solutions Developer
    - Zonecom Communications

    Comment


    • #3
      <form method='post' action='add_rota_type.php' name='add_rota_type' onsubmit='return validateForm()'>
      <input type='submit' value='Save' name='cmdShow' >


      .....Willy

      Comment


      • #4
        Why not just use it as type=submit for the time being rather than type=button. You said thats the only reason you have it up to now, so stick with what you can. Further on, then you acn add more functionality but stick to the above mentioned for now.
        Matt Sartain
        Internet Solutions Developer
        - Zonecom Communications

        Comment


        • #5
          I'm sure the O/P heard you the first time. You may not be aware but the O/P is developing a form which will need to be validated sometime in the future when it is completed. My example accounts for just that.

          .....Willy

          Comment


          • #6
            Thanks!

            Cheers Willy, Don't know why i didnt think of that before, I guess I was thinking that if validation was to be done I wouldn't be able to use submit.

            I presume in the validation I return either true or false depending on the result of the checks.

            Thanks again for your help :-)

            Comment


            • #7
              Re: Thanks!

              Originally posted by heaps21
              I presume in the validation I return either true or false depending on the result of the checks.
              Yes, just return false at the end of each conditional statement and then at the end of the validateForm function, return true.

              .....Willy

              Comment

              Working...
              X