Reputation: 53
lets say i have got two html pages which both contain the same select box:
<select onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">
<option value="/site1.php">Site1</option>
<option value="/site2.php">Site2</option>
</select>
I am looking for a way to pass the value of selectedIndex to the next page, so I can use it at the second page select box too. Any suggestions?
Thanks in advance
Upvotes: 1
Views: 1779
Reputation: 18995
localStorage
Store:
localStorage.userEdits=this.options[this.selectedIndex].value;
Get, on the other page :
var yourIndex = localStorage.userEdits;
hash
Set:
window.location.href="yourURL#index="+this.options[this.selectedIndex].value;
Get:
var yourIndex=window.location.hash.replace("index=","").parseInt();
Upvotes: 1