I'm looking for a way to insert a hidden input on submitting for 'Yes' in my jquery code below.
How do I insert this:
<input type="hidden" name="token" value="1">
From this:
$(function() {
    $( "#dialog" ).dialog({
        autoOpen: false,
        modal: true,
        buttons: {
            "Yes": function() {
                $( '#form' ).submit();
            },
            "No": function() {
                $( '#form' ).submit();
            },
            Cancel: function() {
                $( this ).dialog( "close" );
            }
        }
    });
});
                Try this
$(function() {
    $( "#dialog" ).dialog({
        autoOpen: false,
        modal: true,
        buttons: {
            "Yes": function() {
                $('#form').append('<input type="hidden" name="token" value="1" />').submit();
            },
            "No": function() {
                $('#form').submit();
            },
            Cancel: function() {
                $(this).dialog( "close" );
            }
        }
    });
});
                        Easy answer, first adding the input and then calling submit (I'm guessing a bit of context btw).
$('#form').append('<input type="hidden" name="token" value="1">').submit();
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With