Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a reason this doesn't work?
    text
    copied!<p>A simple HTML form:</p> <pre><code>&lt;form enctype="application/x-www-form-urlencoded" method="post" action="/view/album/id/4"&gt;&lt;ol&gt; &lt;li class="no-padding"&gt;&lt;div class="element"&gt; &lt;input type="hidden" name="media" value="" id="media" /&gt;&lt;/div&gt;&lt;/li&gt; &lt;li class="no-padding"&gt;&lt;div class="button"&gt; &lt;input type="submit" name="add_to_favorites" id="add_to_favorites" value="Add To Favorites" /&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/form&gt; </code></pre> <p>JQuery:</p> <pre><code>$('#add_to_favorites').hover(function() { var id = 10; // alert(id); $('#media').val(id); }); </code></pre> <p>Which basically means that when you hover over the submit button of the form, the jQuery will set 10 as value of the #media hidden field.</p> <p>When I click on the submit button though, the hidden field returns NULL:</p> <pre><code>var_dump($_POST); // this will return: // array(2) { ["media"]=&gt; NULL ["add_to_favorites"]=&gt; NULL } </code></pre> <p>EDIT:</p> <p>I tested both value of "var id" and the hidden field value with alert() and they are properly set.</p> <p>EDIT2:</p> <p>There is one click() event triggered on the page, too, here's the full code:</p> <pre><code>$(document).ready(function() { $('.box-content2 a').click(function() { var path = $(this).attr('href'); var title = $('img', this).attr('alt'); var id = $(this).attr('id'); $('#media-photo img').attr('src', path); $('#media-photo img').attr('alt', title); $('#media-photo img').attr('id', id); return false; }); $('#add_to_favorites').hover(function() { var id = 10; $('#media').val(id); }); }); </code></pre>
 

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