JQuery在多个页面上添加循环

I've created a 3 page PHP form that carries the answers to the next page inside hidden fields. Each page has 3 questions, and depending on your answer, you can be "qualified" or "unqualified". Ideally I would like to count how many "unqualified" answers were selected total for all 3 pages. Here is my current code to count how many "unqualified" answers were selected on one page:

<script type="text/javascript">
    $(function(){
        $('select').on('change', function(e){
            e.preventDefault();
            ct = $('select option.unqualified:selected').length;
            $("input[class=uqNum]").val(ct);
        });
    });
</script>

The script counts how many options with the class "unqualified" were selected and puts that number in a hidden field with class "uqNum".

The problem is when I go to the next page of the form and select another "unqualified" option, the number is then replaced with the number selected on THAT page, and doesn't continue to add to the number from the previous page. I feel like there should be a loop of some kind? How do you continue to add to a value when you go to another page?

If you're using PHP I would change storing the values in hidden options and change it to use Session values. Then each page you can access the values from the previous page.

You need to call session_start() somewhere at the beginning of every php script. Then you can access the values easily $_SESSION['key_name'] = $value;