I would like to retrieve the value of a sessionStorage variable that was set in step 1 of a multi-step pop up to help in the conditional display of text in step 3. All five steps sit within a form and every post is handled by AJAX routines and are working fine.
Does anyone have any ideas about how I can pass the variable (selectedRole) back through to the front end from AJAX so I can use it in step 3?
My code to save the variable is as follows:-
function setUpPopupRegistrationForm() {
$('.js-popup-register-button').on('click', function() {
let storage = window.sessionStorage;
let selectedRole = this.dataset.role;
storage.clear('selectedRole');
storage.setItem('selectedRole', selectedRole);
navigateToNextStep(this);
});
}
<div class="form__step js-popup-register-step" data-step="1">
<h3>
<?php the_field('title_1', 'option'); ?>
</h3>
<div class="d-flex flex-column flex-sm-row justify-content-between">
<div class="button button--blue js-popup-register-button" data-role="member"> <span>Member</span>
</div>
<div class="button js-popup-register-button" data-role="guest"><span>Guest</span></div>
</div>
</div>