After 4-5 hours googling and researching, triggering a form submit doesn't return field values to php as expected ... appreciate any help
<?php
if (isset($_POST['xxxx'])){
echo "POST DELETE <br />";
}else{
?>
<div id="dialog_confirm" title="Confirm Delete">Are you sure ?</div>
<form id='inputform' name='tablename' method='post' action='#' />
<input type='text' name='xxxx' value='22' />
<input type='submit' class='delete' name='delete' value='Delete' />
</form>
<script type='text/javascript'>
jQuery(document).ready(function(){
$('#inputform').submit( function(){
$("#dialog_confirm").dialog('open');
return false;
});
$( "#dialog_confirm" ).dialog({
autoOpen: false,
resizable: false,
height:140,
modal: true,
buttons: {
"Delete all items": function() {
$( this ).dialog( "close" );
window.inputform.submit();
},
Cancel: function()开发者_运维百科 { $( this ).dialog( "close" );}
}
});
});
</script>
It's because you have return false; here:
$('#inputform').submit( function(){
$("#dialog_confirm").dialog('open');
return false;
});
So whenever you try to submit data from the form, it never will. You want to use click() on the submit button instead.
You may want to try this:
$('.delete').click( function(){ //Submit button clicked (or return key pressed)
$("#dialog_confirm").dialog('open');
return false; //Don't submit the form straight away
});
$( "#dialog_confirm" ).dialog({
resizable: false,
autoOpen: false,
height:140,
modal: true,
buttons: {
"Delete all items": function() {
$('#inputForm').submit(); //Now submit the form
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
精彩评论