Access our premium support and let us know your problems, we will help you solve them.

0
No products in the cart.

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • blankjtowell
    Participant

    Can you please try this, I believe it it working fully.

     <script>
     jQuery(document).ready(function($){   
        var session_agent = sessionStorage.getItem('agent');
        console.log('get session value page loaded ' + session_agent);
        if (session_agent == null ){
          console.log('create agent not in session set to Agent1');
          sessionStorage.setItem('agent', 'Agent1');
          $('#agent').val('Agent1');
        }else{
          $('#agent').val(session_agent);
        }
    
        $( document ).on( 'change', '#agent', function() {
            sessionStorage.setItem('agent', $(this).val());
            console.log('update value in session ' + $(this).val());
        });
        
        $( document ).ajaxComplete( function() {
            var session_agent = sessionStorage.getItem('agent');
            console.log('ajax completed get session value and set dropdown ' + session_agent);
            $('#agent').val(session_agent);
        });     
     });
     </script>
    

    I have left the console.log in there to help you with checking it. Obviously these need to be removed in the final version

    You could change it probably to use window.localStorage also but I had already begun this approach, so I left it using session instead. Someone else might be able to advise of the pros and cons.

Viewing 1 post (of 1 total)