Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery function not knowing which selected options to move
    text
    copied!<p>I am using jQuery to slide down and slide up a <code>&lt;div&gt;</code> based on a radio selection.</p> <p>I then have some PHP code that remembers what option was set so if the user navigates to and from the page it will remember if they had "unhidden the box".</p> <p>The code was working yesterday but doesn't seem to be working today. I have tried debugging but with no luck.</p> <p>jQuery:</p> <pre><code> $('.children-under-18-yes').click(function(){ $('.children-guardians').slideDown(); }); $('.children-under-18-no').click(function(){ $('.children-guardians').slideUp(); }); </code></pre> <p>PHP/HTML</p> <pre><code> &lt;h2&gt;Are any of the children under 18 years old?&lt;/h2&gt; &lt;li&gt; &lt;label class="radio"&gt;&lt;input type="radio" name="children_under_18" id="children_under_18" group="underage" class="children-under-18-yes" value="yes"&lt;?php echo stickyRadio('children_under_18','yes');?&gt; /&gt;Yes&lt;/label&gt; &lt;label class="radio"&gt;&lt;input type="radio" name="children_under_18" id="children_under_18" group="underage" class="children-under-18-no" value="no"&lt;?php echo stickyRadio('children_under_18','no');?&gt; /&gt;No&lt;/label&gt; &lt;/li&gt; &lt;br class="clear" /&gt; &lt;div class="children-guardians"&lt;?php echo isset($_SESSION['chidren_under_18']) &amp;&amp; $_SESSION['chidren_under_18'] != 'no' ? 'style="display: block;"' : 'style="display: none;"' ?&gt;&gt; &lt;h3&gt;As you answered yes, please provide the names of those persons you want to serve as guardians of your minor child(ren) in the event of your death. &lt;/h3&gt; &lt;li&gt; &lt;label class="float"&gt;1st Choice Guardian&lt;/label&gt; &lt;input type="text" name="1st_guardian" id="1st_guardian" value="&lt;?php echo stickyText('1st_guardian'); ?&gt;" /&gt; &lt;/li&gt; &lt;li&gt; &lt;label class="float"&gt;2nd Choice Guardian&lt;/label&gt; &lt;input type="text" name="2nd_guardian" id="2nd_guardian" value="&lt;?php echo stickyText('2nd_guardian'); ?&gt;" /&gt; &lt;/li&gt; &lt;/div&gt; </code></pre> <p>Session posting (from Page)</p> <pre><code>if(empty($missing)) { post2session(array('children')); $_SESSION['step'][2] = 2; if(isset($url)) { redirect($url); } } </code></pre> <p>Session post function</p> <pre><code> function post2session($parts = array()) { $out = array(); foreach($_POST as $key =&gt; $value) { $value = is_array($value) ? $value : trim($value); $par = explode("#",$key); if(in_array($par[0],$parts)) { $out[$key] = $value; } else { $_SESSION[$key] = $value; } } if(!empty($out)) { foreach($_SESSION as $key =&gt; $value) { $par = explode("#",$key); if(in_array($par[0],$parts) &amp;&amp; !array_key_exists($key,$out)) { unset($_SESSION[$key]); } } foreach($out as $key =&gt; $value) { $_SESSION[$key] = $value; } } else { foreach($_SESSION as $key =&gt; $value) { $par = explode("#",$key); if(in_array($par[0],$parts)) { unset($_SESSION[$key]); } } } } </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