show hidden rows when returning to a page and a radio button is selected

62 Views Asked by At

warning, I am a novice when it comes to JQuery.

I am creating a form where I have successfully able to hide table rows when the user initially gets on the page. When the user selects a radio button, I am also able to show those hidden rows so the user is able to answer those questions.

The issue I am having is the user is allowed to return to the same page and would like to view/edit their answers, the answer they chosen previously is selected but my hidden rows do not show.

In IE, if I reselect the same option, the hidden rows then show. In Chrome, I have to change my selection then the hidden rows show.

I would prefer the hidden rows to show when the user returns on the page, is anyone able to help me?

data-id=q1y - my hidden row data-id=q1 - my question Y1, Y2, Y3 - different answers to data-id=q1

<script type="text/javascript">

  sits_attach_event(window,"load",moreInfo);



        function moreInfo(){

            $("[data-id=q1y]").hide();
            $("[data-id=q1]").change(function(){

                if ($("[data-id=q1] :checked").val() == "Y1" || $("[data-id=q1] :checked").val() == "Y2" || $("[data-id=q1] :checked").val() == "Y3"){

                    $("[data-id=q1y]").show();
                } else{
                    $("[data-id=q1y]").hide();
                }

            }); 

        };

</script>   
0

There are 0 best solutions below