I've used some code from another question asked years ago Implement jQuery confirmation modal in a form submit?
but that question didn't go far enough to show how a form could be submitted when responding with Yes and I haven't been able to get this to work.
You will see all the ways I've tried to make work (they are commented out). Does anybody know what I'm doing wrong here?
<div id="dialog-confirm" title="Ready?">
<p>Are you sure?</p>
</div>
<form action"" id="myform" name="myform2" type="post">
<input type="submit" value="Yes" name="moveOn" />
</form>
<script>
$(function() {
$("#dialog-confirm").dialog({
resizable: false,
height:190,
autoOpen: false,
width: 330,
modal: true,
buttons: {
"Yes": function() {
//$('#myform')[0].submit();
//document.myform2.submit();
//document.getElementById("#myform").submit();
},
No: function() {
$(this).dialog("close");
}
}
});
$('#myform').submit(function() {
$("#dialog-confirm").dialog('open');
return false;
});
});