title: jQuery - Form input return confirm to delete
body: <p>I struggled a lot before posting here :) now, I want to replace my default javascript confirmation for deleting a file. I saw a lot of examples here, but no example with form input. </p>
  
  <p>Now I have his form:</p>
  
  <pre><code>&lt;form action="delete.php" method="post"&gt;
  &lt;input type="hidden" name="id" value="&lt;{$pid}&gt;" /&gt;
  &lt;input type="hidden" name="picture" value="&lt;{$lang_del_pic}&gt;" /&gt;
  &lt;input type="image" src="&lt;{xoImgUrl}&gt;img/del-icon.gif" width="16" height="16" align="bottom" border="0" alt="Delete media" name="pictured" value="&lt;{$lang_del_pic}&gt;" onclick="javascript: return confirm('&lt;{$lang_confirm_del}&gt;');" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Now, I did everything, I have this div:</p>
  
  <pre><code>&lt;div id="dialog-confirm" title="Empty the recycle bin?"&gt;
   &lt;p&gt;&lt;span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"&gt;&lt;/span&gt;These items will be permanently deleted and cannot be recovered. Are you sure?&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>this javascript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
   $(function() {
    // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
    $("#dialog").dialog("destroy");
  
  
    $("#dialog-confirm").html('This dialog will show every time!');  
    $("#dialog-confirm").dialog({
     autoOpen: false,
     title: 'Kur za berbatov',
     resizable: false,
     height:140,
     modal: true,
     buttons: {
      'Delete all items': function() {
       document.location = 'delete.php';
  
      },
      Cancel: function() {
       $(this).dialog('close');
      }
     }
    });
  
  
    $('form#dialog-confirm').submit(function(){
              $("input#pictured").html($("input#pictured").val());
              $('#dialog').dialog('open');
              return false;
          }); 
  
  
    $('input#opener').click(function() {
     $('#dialog-confirm').dialog('open');
    }); 
  
   });
   &lt;/script&gt;
  </code></pre>
  
  <p>and this new form:</p>
  
  <pre><code>&lt;form name="dialog-confirm"  id="dialog-confirm" method="post"&gt;
  &lt;input type="hidden" name="id" value="&lt;{$pid}&gt;" /&gt;
  &lt;input type="hidden" name="picture" value="&lt;{$lang_del_pic}&gt;" /&gt;
  &lt;input type="image" src="&lt;{xoImgUrl}&gt;img/del-icon.gif" width="16" height="16" align="bottom" border="0" alt="Delete media" name="pictured" value="" id="opener"  /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>On press, I call successfuly the jQuery modal diolog, and everything works, but somehow, when I press 'delete all' the script tells me - "the script is called without the necessary parameters"</p>
  
  <p>Now I guess I am failig to send the pic ID to be deleted with the jQuery, .. but do not know how to fix it. Any ideas ? </p>
  
  <p><strong>Update</strong></p>
  
  <p>Well, I have posted the original form, the new form, and the jQuery... I really can not do it... please take a look at the post up.</p>
  
  <p>Is there no way doing it as I posted it, without an submit button. I mean the original works fine, however, I have hard times implementing it in the jQuery</p>
  
  <p>P.S. I messedup with my accounts here, this is a new one :)</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>Now this should work according all tutorials. But the delete button still does not submit the form... Why is that, please help me..</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
          $(function() {
              // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
              $("#dialog").dialog("destroy");
  
  
              $("#dialog-confirm").html('This dialog will show every time!');     
              $("#dialog-confirm").dialog({
                  autoOpen: false,
                  title: 'Kur za berbatov',
                  resizable: false,
                  height:140,
                  modal: true,
                  buttons: {
                      'Delete all items': function() {
                          document.dialog-confirm.submit(); 
  
                      },
                      Cancel: function() {
                          $(this).dialog('close');
                      }
                  }
              });
  
  
              $('form#dialog-confirm').submit(function(){
                  $('#dialog-confirm').dialog('open');
                  return false;
              }); 
  
          });
          &lt;/script&gt;
  
  
  
  &lt;form action="delete.php" name="dialog-confirm"  id="dialog-confirm"  method="post"&gt;
  &lt;input type="hidden" name="id" value="&lt;{$pid}&gt;" /&gt;
  &lt;input type="hidden" name="picture" value="&lt;{$lang_del_pic}&gt;" /&gt;
  &lt;input type="image" src="http://7est2.mqsto.com/themes/exnews/img/del-icon.gif" width="16" height="16" align="bottom" border="0" alt="Delete media" name="pictured" value="" id="opener"  /&gt;
  &lt;/form&gt;
  </code></pre>