【发布时间】:2016-02-21 10:59:24
【问题描述】:
目前正在处理会话存储,用户必须从第一页中选择一个单选按钮并单击下一步按钮 div 必须在第一页的第二页中显示我已经创建了一个函数,其中包含一组对象第二次使用 set item 存储我试图使用 get item 获取这些值。
我有两种情况
- 当用户从第一个无线电组中选择 pg 单选按钮时,如果有任何位置,如 alain / abudhabi 如果用户选择 alain | abudhabi 从位置 从位置然后用户选择 DIP EDU 如果用户单击提交按钮然后在第二页中我需要获得一个复选框并创建应用程序按钮其余的应该被隐藏 - 使用我的代码正在工作
- 如果用户从第一个单选组中选择 ug 单选按钮,并且如果用户单击提交按钮,则在第二页中,如果有任何位置,例如 alain / abudhabi,则我需要获取 Just a Pay 按钮 ,但这不是很好帮帮我
这是我的plunker link,就像小提琴一样
这是我从第一页获取项目的代码
function storedata(){
var storeDate = {};
storeDate['storedValue1'] = $('input[id=pg]:checked').val();
storeDate['storedValue2'] = $('#alain').prop('checked'),$('#abudhabi').prop('checked');
storeDate['storedValue3'] = $('#slt_mjrpg option:selected').val("Dip - Prof. PG Dip in Teaching");
sessionStorage.setItem('storeDate', JSON.stringify(storeDate));
}
function storedata1(){
var storeDate1 = {};
storeDate1['storedValuej'] = $('#slt_mjr option:selected').val("Bachelor of Arts in Persian").text();
sessionStorage.setItem('storeDate1', JSON.stringify(storeDate1));
console.log(storeDate1);
}
当我签入会话存储时,我将 storedValue2 设为 false
提供后或在此行
storeDate['storedValue2'] = $('#alain').prop('checked') || $('#abudhabi').prop('checked');
我在 storedValue2 = true 中得到了正确的结果,但我的输出没有按预期工作
在第二页
var otherObj = JSON.parse(sessionStorage.getItem('storeDate'));
var otherObj1 = JSON.parse(sessionStorage.getItem('storeDate1'));
if (otherObj.storedValue1 && otherObj.storedValue2 && otherObj.storedValue3 != "pg") {
$(".pay_check,.pay_click").show();
$(".pay_trans").hide();
} else if (otherObj1.storedValuej === "BAP") {
$('.create_btn,.no_applica').show();
$('.pay_btn').hide();
} else { * * // I have tried using like this but no use**
//$('.create_btn,.no_applica,.pay_click').hide();
$('.pay_btn').show();
}
对这个问题有任何建议
请指导我哪里做错了。提前致谢
【问题讨论】:
-
Here's您的特殊代码请求:)
-
@PDKnight 非常感谢你的震撼:)
标签: javascript jquery html json session-storage