Note that there are some explanatory texts on larger screens.

plurals
  1. POSend input values from main window to fancybox iframe correctly
    text
    copied!<p>I was wondering if someone could help me. I have made a simple plugin for Wordpress using php. It's a gallery that allows the user to add captions and custom fields for the images.. The forms are displayed using a Fancybox, that is opened by clicking input- buttons...</p> <p>The edit-function looks like this:</p> <pre><code>$(".edit").click(function() { var formData = $(this).closest('form').serializeArray(); formData.push({ name: this.name, value: this.value }); //this is to get the submit-buttons value $.fancybox.showActivity(); $.ajax({ type : "POST", cache : false, url : "&lt;?php echo plugins_url(); ?&gt;/upload/ editImageForm.php", data : formData, success: function(data) { $.fancybox(data); } }); return false; }); </code></pre> <p>Since the edit-form needs the imageID to edit the right image- information I currently send it through a hidden field.</p> <p>My problem is that I want the Edit-form to be displayed inside a Iframe, so that when submitting the edit-form the form-action-page appears inside the iframe. Currently the form-action-page loads in the main window.. and exit from the wordpress admin-area.. How do I use an iframe for the Edit-form, and how do I send input values from a form in the main window, to the fancybox-iframe (with the edit-form inside)?</p> <p>The HTML for the form that opens the fancybox looks like this, this is displayed next to each image in the overview page:</p> <pre><code>&lt;form method='post' action='' class="imageform"&gt; &lt;input type='submit' value='Edit' name='edit' class="edit imageButton" /&gt; &lt;input type='submit' value='Delete' name='delete' class="delete imageButton" onClick="return delete('&lt;?php echo $image-&gt;name; ?&gt;', '&lt;?php echo $image-&gt;id; ?&gt;')"/&gt; &lt;input name='imageID' type='hidden' value='&lt;?php echo $image-&gt;id; ?&gt;' class="imageID" /&gt; &lt;input name='imageNavn' type='hidden' value='&lt;?php echo $image-&gt;name; ?&gt;' class="imageNavn" /&gt; &lt;/form&gt; </code></pre> <p>(The delete-function on the delete button only display a confirm-box in javascript, asking if the user are sure he/she wants to delete the image..)</p> <p>The Add Image-form is a bit simpler works as it should, and the iframe displays correctly:</p> <pre><code>$("#upload").click(function() { $.fancybox.showActivity(); $.fancybox({ 'type' : 'iframe', 'width' : '50%', 'height' : '75%', 'href' : '&lt;?php echo plugins_url(); ?&gt;/upload/ addImage.php' }); }); </code></pre> <p>Hopefully you understand my problem and will be able to help me ;)</p> <p>Thanks in advance! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload