Basically i have two radio button inputs if value A (yes) is clicked then i want it to display the a hidden div.
If value No is clicked i want it to hide the div or do nothing if it's already hidden.
I have the above ok with the following jQuery;
$('.minor_yes').click(function开发者_开发问答(){
$('.underage').slideDown();
});
$('.minor_no').click(function(){
$('.underage').slideUp();
});
My issue is, i am using sessions so there is some page navigation if the user navigates away from the page, it stores his selection on the form,
i.e. if the user selected yes it will still display yes.
But the div is hidden again and will not initiate on page reload.
How would i do this?
Probably the easiest way to do this is to use php to set the visibility of the element from your session variable:
<div class="underage"
<?= isset($_SESSION['sessVar']) ? "style=\"display: block;\"" : "style=display: none;\"" ?>>Hidden content</div>
assuming PHP..
<input type=radio name=minor class='minor_yes' <?php $_SESSION['minor_yes']==true?echo'Selected':echo'';?> >
<input type=radio name=minor class='minor_no' <?php $_SESSION['minor_yes']==falsee?echo'Selected':echo'';?> >
<div class="minor_yes_content" style="display:<?= isset($_SESSION['sessVar']) ? "block" : "none" ?>;"> </div>
精彩评论