Submiting a form using javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bizt

    Submiting a form using javascript

    Hi,

    First let me point out I have googled this and also must have done
    this operation a dozen times (altho a few years ago) but for some
    reason I cant get a form to submit using javascript .. Ive tried both
    FF and IE. All the pages that I look at all say the same way which is
    the way Im sure Ive done it before:


    My code is:

    (javascript function)

    function DeleteImages (oForm) {
    alert('submitti ng form') // this works ...
    oForm.submit() // this doesnt!!
    }

    (html button)

    <input type="button" name="submit" value="Delete Selected"
    onclick="Delete Images(this.for m);" />


    Maybe just a sanity check is needed but I cant see what the problem
    is. Where am I going wrong? I know that the function is being called
    because the alert message is executing but the form isnt submitting.

    Cheers

    Burnsy
  • RobG

    #2
    Re: Submiting a form using javascript

    On Feb 13, 10:15 pm, bizt <bissa...@yahoo .co.ukwrote:
    First let me point out I have googled this and also must have done
    this operation a dozen times (altho a few years ago) but for some
    reason I cant get a form to submit using javascript .. Ive tried both
    FF and IE. All the pages that I look at all say the same way which is
    the way Im sure Ive done it before:
    [...]
    <input type="button" name="submit" value="Delete Selected"
    onclick="Delete Images(this.for m);" />
    Browsers make named controls available as properties of the DOM form
    object. Giving any control a name of 'submit' shadows the form's
    submit method, so form.submit() is equivalent to
    form.elements['submit']().

    There is rarely any need to name a submit button, remove the name (or
    change it to something other than 'submit') and life will return to
    normal...


    --
    Rob

    Comment

    • Gregor Kofler

      #3
      Re: Submiting a form using javascript

      RobG meinte:
      There is rarely any need to name a submit button
      There is. Frequently. When your server-side script wants to know,
      whether you hit "cancel" or "delete" or "save"...

      Gregor


      --
      http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
      http://web.gregorkofler.com ::: meine JS-Spielwiese
      http://www.image2d.com ::: Bildagentur für den alpinen Raum

      Comment

      • Zvonko Biskup

        #4
        Re: Submiting a form using javascript


        "Gregor Kofler" <usenet@gregork ofler.atwrote in message
        news:KEFsj.95$Z 67.142@nntpserv er.swip.net...
        RobG meinte:
        >
        >There is rarely any need to name a submit button
        >
        There is. Frequently. When your server-side script wants to know, whether
        you hit "cancel" or "delete" or "save"...
        So? Can't you name it 'delete', 'cancel' and 'save'?




        Comment

        • RobG

          #5
          Re: Submiting a form using javascript

          On Feb 14, 3:13 am, Gregor Kofler <use...@gregork ofler.atwrote:
          RobG meinte:
          >
          There is rarely any need to name a submit button
          >
          There is. Frequently. When your server-side script wants to know,
          whether you hit "cancel" or "delete" or "save"...
          I guess you mean where a form has multiple submit buttons to indicate
          which of a number of actions to take when the form is submitted - the
          name can be used to determine which button was used to submit it.

          That's certainly one case where naming the button is useful, athough
          the same functionality can be provided using a single submit button
          and say checkboxes or radio buttons to indicate the action to take.


          --
          Rob

          Comment

          • Gregor Kofler

            #6
            Re: Submiting a form using javascript

            RobG meinte:
            On Feb 14, 3:13 am, Gregor Kofler <use...@gregork ofler.atwrote:
            >RobG meinte:
            >>
            >>There is rarely any need to name a submit button
            >There is. Frequently. When your server-side script wants to know,
            >whether you hit "cancel" or "delete" or "save"...
            >
            I guess you mean where a form has multiple submit buttons to indicate
            which of a number of actions to take when the form is submitted - the
            name can be used to determine which button was used to submit it.
            >
            That's certainly one case where naming the button is useful, athough
            the same functionality can be provided using a single submit button
            and say checkboxes or radio buttons to indicate the action to take.
            Agreed, but I wouldn't call that good usability.
            "
            I want to

            [ ] cancel editing
            [ ] save this record
            [ ] delete this record

            [ Go >]
            "

            When have you last seen such a form? (It makes sense for multiple
            entries, though.)

            Gregor


            --
            http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
            http://web.gregorkofler.com ::: meine JS-Spielwiese
            http://www.image2d.com ::: Bildagentur für den alpinen Raum

            Comment

            • Gregor Kofler

              #7
              Re: Submiting a form using javascript

              Zvonko Biskup meinte:
              "Gregor Kofler" <usenet@gregork ofler.atwrote in message
              news:KEFsj.95$Z 67.142@nntpserv er.swip.net...
              >RobG meinte:
              >>
              >>There is rarely any need to name a submit button
              >There is. Frequently. When your server-side script wants to know, whether
              >you hit "cancel" or "delete" or "save"...
              >
              So? Can't you name it 'delete', 'cancel' and 'save'?
              Sure. But you *named* it.

              Gregor


              --
              http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
              http://web.gregorkofler.com ::: meine JS-Spielwiese
              http://www.image2d.com ::: Bildagentur für den alpinen Raum

              Comment

              Working...