开发者

JQuery Submit Hidden Form

I know this is simple but I can't figure it out today and I can't find the right solution.

I have a series of tabs which populate data. At the end is a confirmation tab. At this point they can click a 'submit' button. When this button is pressed a hidden form is populated with all the relevant data. I'd like this form to then be submitted but I can't figure out how to submit the form with JQUery. I've attempted to do a trigger on the button but perhaps I'm doing it wrong. Below is a sample of the code for the button taht gets clicked. Note the values populate, I just can't get the form to submit

  $('#submitAppointment').click(function() {
        $("#" + formName + "schedule_id option[value='" + $("input[name=开发者_开发知识库'appointmentTime']:checked").val() + "']").attr('selected', 'selected');      
        $("#" + formName + "apt_date").val($("#confirmDate").text());
        $("#" + formName + "first_name").val($("#confirmFirstName").text());
        $("#" + formName + "last_name").val($("#confirmLastName").text());
        $("#" + formName + "email").val($("#confirmEmail").text());
        $("#" + formName + "phone").val($("#confirmPhone").text());
        $("#" + formName + "notes").val($("#confirmNotes").text());
        $('#appt_form').submit(function() {
            alert('Handler for .submit() called.');
            return false;
        });
    });

Any ideas on what I'd need to do to rigger the submit function?


How about

$('#appt_form').submit();

Don't return false from the handler function if you want the form submission to actually proceed. If your intention is to have the form post without the page refreshing, then you're talking about an ajax operation for which you could use $.post(). (It's not clear that that's what you want to do however.)


Assuming the form you want to submit is found by the #appt_form selector, just use .submit in the no-argument form (which is simply an alias for .trigger('submit'))

$('#appt_form').submit();


I think you should try calling

$('#appt_form').submit()

if appt_form is your form id. That command should submit the form, based on jQuery documentation.

Here is jQuery submit function documentation

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜