Tuesday, May 28, 2024
 Popular · Latest · Hot · Upcoming
63
rated 0 times [  67] [ 4]  / answers: 1 / hits: 47845  / 9 Years ago, sun, november 8, 2015, 12:00:00

Working on Session storage where in the first page I have a drop down if user select (.bap_mjr) value from the drop-down and click next button from the first page It will redirect to the second page where I need to show an label.



First page HTML



  <select class=mslt_Field slt_major slt_mjr ipt_required id=slt_mjr name=slt_mjr>
<option value=>Please Select</optio
<option value=BA in Arts,Culture&Heritage Ma>BAACHM</option>
<option id=bap_Mjr class=bap_Mjr value=Bachelor of Arts in Persian>BAP</option>
<option value=Bachelor of Bus Adminstration>BBA</option>
</select>


Currently I am trying In First Page this is my jquery code



$(#slt_mjr).change(function (){
alert($(this).val());
var dropselvalue = -1;
if (document.getElementById(bap_Mjr).val())
{
alert(check);
dropselvalue = 1;
}
if(window.sessionStorage) {
sessionStorage.setItem(dropselvalue, dropselvalue);
}
});


Second page



<div class=pay_click>Welcome to second page</div>


Second page jquery code



var dropselvalue = parseInt(sessionStorage.getItem(dropselvalue));
if (dropselvalue != -1) {
if (dropselvalue === 1) {
$(.pay_click).show()
}
//localStorage.removeItem(CheckedRadioValue);
}


The session was not stored and I am not able to get the item.



Where I am doing mistake kindly help me



Thanks in advance


More From » jquery

 Answers
24

you had an incomplete ending tag, and you were using .val() on javascript, not jquery.



try this code:



html, first page:



<select id=slt_mjr name=slt_mjr>
<option value=>Please Select</option>
<option value=BA in Arts,Culture&Heritage Ma>BAACHM</option>
<option id=bap_Mjr class=bap_Mjr value=Bachelor of Arts in Persian>BAP</option>
<option value=Bachelor of Bus Adminstration>BBA</option>
</select>
<a href=deleteme1.html>Link to second page</a>


javascript, first page:



$(#slt_mjr).change(function () {
//alert($(this).val());
var dropselvalue = -1;
if ($(#bap_Mjr).val()) {
dropselvalue = 1;
}

if (window.sessionStorage) {
sessionStorage.setItem(dropselvalue, dropselvalue);
}
});


html, second page:



<button id=check>Check</button>


javascript, second page



$('#check').click(function () {
var dropselvalue = parseInt(sessionStorage.getItem(dropselvalue));
if (dropselvalue != -1) {
if (dropselvalue === 1) {
alert();
}
//localStorage.removeItem(CheckedRadioValue);
}
});

[#64470] Thursday, November 5, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yosefleod

Total Points: 113
Total Questions: 100
Total Answers: 115

Location: Egypt
Member since Tue, May 3, 2022
2 Years ago
;