开发者

jquery.ui dialog confirming delete not returning values to php

开发者 https://www.devze.com 2023-02-24 08:06 出处:网络
After 4-5 hours googling and researching, triggering a form submit doesn\'t return field values to php as expected ... appreciate any help

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" );
                }
            }
 });
0

精彩评论

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