开发者

form does not submit and refresh back to same page when return false is added

i have previously posted about triggering a dialog box before 开发者_Python百科confirming a submit. But, unfortunately the document now does not submit. Instead, it stays on the same page with the exact same setting. I have tested, if i remove the return false over at submitform function, the document submit will go through but it would not be triggered by "proceed" button. So in this case, i believe the return false has to be around but how can i ensure my document will and only submit successfully after clicking "proceed"? I think this is purely a javascript problem because my back end works.

    <script type="text/javascript">
        function submitform(){
        $("#dialog-submit").dialog("open");
        return false
    }

    $("#dialog-submit").dialog({
        autoOpen: false,
        resizable: false,
        height: 200,
        width: 200,
        modal: true,
        buttons: {
            "Proceed": function(){
                //submit.
        //tried document.submitform.submit();  does not work either         
                document.forms[0].submit();
                $(this).dialog("close");

            }
        }
    });
     </script>


 <form name="submitform" action="{{ request.path }}" method="post" enctype="multipart/form-data">
     <input type="image" src="{{ MEDIA_URL }}images/submit.png" title="Submit Iteration" name="submitIter" onclick="return submitform();" value="{{ i.iter.key.id }}" width="25px"/>
 </form>


You should try writing your code as unobtrusive javascript.

Here's an example on jsfiddle for a fix.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜