目前处理会话存储,如果用户从第一页和下一页中选择一个单选按钮,我必须显示第二个单选按钮的一个div和相似度这里有两个场景
使用我当前的代码第一个方案工作正常,但第二个方案部分工作意味着我得到div但它没有隐藏第一个div我想删除会话存储
这里我使用带数组的json
function storedata() {
var storeDate = {};
storeDate['storedValue1'] = $('input[id=pg]:checked').val();
storeDate['storedValue2'] = $('input[id=alain]:checked').val();
storeDate['storedValue3'] = $('#slt_mjrpg option:selected').val("Dip - Prof. PG Dip in Teaching");
sessionStorage.setItem('storeDate', JSON.stringify(storeDate));
console.log(storeDate);
}
function storedata1() {
var storeDate1 = {};
storeDate1['storedValuej'] = $('#slt_mjr option:selected').val()
sessionStorage.setItem('storeDate1', JSON.stringify(storeDate1));
console.log(storeDate1);
}
在第二页
var otherObj === JSON.parse(sessionStorage.getItem('storeDate'));
if (otherObj.storedValue1 && otherObj.storedValue2 && otherObj.storedValue3) {
console.log(otherObj);
$(".div_show").show();
}
var otherObj1 === JSON.parse(sessionStorage.getItem('storeDate1'));
if (otherObj1.storedValuej) {
console.log(otherObj1);
$(".div_show1").show();
}
这是html页面第一组
<div class="edu">
<input type="radio" id="ug" name="edu" class="ug" value="ug" checked="checked">
<label class="radio-label">Undergraduate</label>
<input type="radio" id="pg" name="edu" value="pg" class="pg">
<label class="radio-label">Postgraduate</label>
<input type="radio" id="cu" name="edu" value="cu" class="cu">
<label class="radio-label">Continuing Education</label>
</div>
这是第一个html页面中的第二个广播组
<div class="rad_cam">
<input type="radio" id="abudhabi" name="cam" value="abudhabi" checked>
<label class="radio-label">Abu Dhabi</label>
<input type="radio" id="alain" name="cam" value="alain">
<label class="radio-label">Al Ain</label>
</div>
这是第一个html页面中的第三个元素
<select class="mslt_Field slt_mjrpg ipt_required" id="slt_mjrpg" name="slt_mjrpg">
<option value="">Please Select</option>
<option value="Dip - Prof. PG Dip in Teaching ">DIP EDU</option>
<option value="Master of Science in Finance ">MASF</option>
<option value="MBA">MBA 2013</option>
<option value="MHRM">MHRM </option>
<option value="MHRM">MHRM 2005</option>
<option value="PhD-Doctor of Business Admin">PHDBA</option>
</select>
这是我的第二个HTML页面
<div class="div_show">First</div>
<div class="div_show1">Second</div>