Dynamic form submission through Java Script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chanchal21pes
    New Member
    • Dec 2007
    • 2

    Dynamic form submission through Java Script

    please some one give me a simple code for this
  • Ranjan kumar Barik
    New Member
    • Aug 2007
    • 95

    #2
    Originally posted by chanchal21pes
    please some one give me a simple code for this
    Hi,
    You can define a function like this;
    [CODE=javascript]
    function submit()
    {
    document.form.s ubmit();
    }
    [/CODE]
    inside the script tag or in your javascript file and call it anywhere you like, to submit the page.

    Happy Programming !
    :)

    Comment

    • jhardman
      Recognized Expert Specialist
      • Jan 2007
      • 3405

      #3
      You can also put this just inside nearly any HTML tag:
      [CODE=html]
      onClick="docume nt.form.submit( )"
      [/CODE]

      Comment

      • Ranjan kumar Barik
        New Member
        • Aug 2007
        • 95

        #4
        Originally posted by jhardman
        You can also put this just inside nearly any HTML tag:
        [CODE=html]
        onClick="docume nt.form.submit( )"
        [/CODE]
        Yes,
        you are right. But I think, if we have to submit after validating some form fields then it would be better to have a user defined function for validating and then submitting.

        And I am not sure but this one;
        Code:
        onClick="this.submit()"
        may work.

        Thanks.
        Merry Christ mass!
        :)

        Comment

        • jhardman
          Recognized Expert Specialist
          • Jan 2007
          • 3405

          #5
          Originally posted by Ranjan kumar Barik
          And I am not sure but this one;
          Code:
          onClick="this.submit()"
          may work.
          If the element is in a form, it would work like this:
          Code:
          onClick="this.form.submit()"
          you need to reference the form since it is the form that is submitted. Good point about the function, by the way.

          Jared

          Comment

          • Ranjan kumar Barik
            New Member
            • Aug 2007
            • 95

            #6
            Originally posted by jhardman
            If the element is in a form, it would work like this:
            Code:
            onClick="this.form.submit()"
            you need to reference the form since it is the form that is submitted. Good point about the function, by the way.

            Jared
            Thanks a lot.
            Have a good day!
            :)

            Comment

            Working...