0

For some reason everything works with my code but the form will not submit.

$(function(){

            $("#dialog").dialog({
                    autoOpen:false,
                    bgiframe: true,
                    resizable: false,
                    //height:auto,
                    width:500,
                    modal: true,
                    overlay: {
                        backgroundColor: '#000',
                        opacity: 0.5
                    },
                    buttons: {
                        'I Agree': function() {
                            $(this).dialog('close');
                            $('#form1').submit()                    

                        },
                        'I Do Not Agree': function() {
                            $(this).dialog('close');
                            return false;
                        }
                    }
                });

            $("#submit").click(function(){

                $("#dialog").dialog('open');


            });
        });
mikelbring
  • 1,492
  • 2
  • 13
  • 24

3 Answers3

1

Turns out I needed my button outside of the form tag.

mikelbring
  • 1,492
  • 2
  • 13
  • 24
0

I'd guess (you haven't shown the HTML) that the form contains a form control with the name or id submit which clobbers the submit method of the form.

The easiest solution is to rename the control, otherwise see How to reliably submit an HTML form with JavaScript?

Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Actually I used a button, there is no element with the name submit. – mikelbring Jan 18 '10 at 16:14
  • 1
    Hint: "I'd guess (you haven't shown the HTML)" implies that it would be a good idea to provide some more of your code. Preferably also a link to the page in question. – Quentin Jan 18 '10 at 16:21
0

Is that a copy/paste of your code? Because you're actually missing a semicolon at the end of the $('#form1').submit().

Matt
  • 41,216
  • 30
  • 109
  • 147