0

I want the download now button to submit the form. I have tried

getElementById("forms").submit();
$("form").submit();
$("#forms").submit();

and still nothing works.

The UI pops up and does everything else it is suppose it but does not submit the form

Java script

    $(document).ready(function(){
    $("#dialog-download ").dialog({
        autoOpen: false,
        resizable: false,
        height: 140,
        width: 325,
        modal: true
    });
    $(".opener").click(function(){
        var that = this;
        var checkbox = $(that).next(":checkbox");

        $("#dialog-download").dialog("option", {
            buttons: {
                "Download Now": function(){
                    $(checkbox).prop("checked", !$(checkbox).attr("checked"));
                    $("#dialog-download").dialog("close");
            $("#forms").submit();
                },
                "Download Later ": function(){
                    $(checkbox).prop("checked", !$(checkbox).attr("checked"));
                    $("#dialog-download").dialog("close");
                },
                "Cancel": function(){
                    $("#dialog-download").dialog("close");
                }
            }
        });
        $("#dialog-download").dialog("open");
    });
});

HTML

<div id="dialog-download" title="Download Now?">
    <p><span style="float:left; margin:0 7px 20px 0;"></span>Download the file now or later?</p>
</div>

<form id = "forms" method="post" action="<?php echo $PHP_SELF;?>">
<a class="opener" href="#">db1.csv:</a>
<input id="c1" type="checkbox" name="download[]" value="db1.csv" /><br />
<...>
<input id="submit" type="submit" name="submit" value="submit" >
</form>
2
  • Works for me. jsfiddle.net/Fj2cC/2 The error has to be in your action. Commented May 1, 2012 at 18:59
  • When I click the Download Now button the alert does not show up Commented May 1, 2012 at 19:08

1 Answer 1

1

See the jQuery doc on submit().

Forms and their child elements should not use input names or ids that conflict with properties of a form, such as submit, length, or method. Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see DOMLint.

http://jsfiddle.net/Fj2cC/4/

Sign up to request clarification or add additional context in comments.

1 Comment

That was one of the problems the other one was my if (!isset($_POST['submit'])) i had to change it to if (!isset($_POST['download']))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.