简体   繁体   中英

More submit button disabling on click with Jquery, doesn't work

I got this code here :

It works fine as far as disabling and replacing the Submit button goes, but it will not submit the form. My form uses the 'get' method and submits data to another page.

 <script type="text/JavaScript">
    $('.button').click(function() {
        $('.button').remove();
        $('.holder').append("DONT DOUBLE CLICK ANYTHING IN A BROWSER");
        $('.form').submit();
    });
    </script> 

I have tried most things, including changing .form to the id of my form, still no joy, any ideas would be helpful.

HTML code

<form action="liftingConfirm.asp" method="get" id="frmArchiveConfirm">
<input name="con_id" type="hidden" id="con_id" value="<%=request.querystring("con_id")%>" />
<input name="sub_id" type="hidden" id="sub_id" value="1" />
<input name="liftingDate" type="hidden" id="liftingDate" value="<%=Session("currentUSDate")%>" />
<div class="holder"><input name="btnConfirm" type="submit" class="button" id="btnConfirm" value="Start New Lifting Gear Examination"  /></div>

You're using the wrong selector, the .form is looking for a <form> with a class of form . Furthermore you should be using the on() syntax:

$('form').on('click', '.button', function() {
    $('.holder').append("DONT DOUBLE CLICK ANYTHING IN A BROWSER");
    $('#frmArchiveConfirm').submit();
    $('.button').remove();
});

For your jQuery code to work you should include the frmArchiveConfirm to your jQuery code as below.

Replace $('.form').submit(); with $('#frmArchiveConfirm').submit();

else if you only having one form in the page just use $('form').submit();

When you come across bug like this don't forget to make use of the firebug or the browser development tools. You can easily figure out the bug and what's wrong in your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM