admin管理员组文章数量:1335624
I have;
<form method="post" action="search.php">
<select name="country" class="dropdownselect" >
<option value="">Select Country</option>
<option value="Afghanistan" selected="selected">Afghanistan</option>
<option value="Albania" selected="selected">Albania</option>
<option value="Algeria" selected="selected">Algeria</option>
</select>
</form>
And then in search.php;
$country = $country;
+
SQL query for $country..
I need to save DropDown selection to stay selected when someones preform search.
Can it be done with HTML5 storage func?
Thanks in advance
I have;
<form method="post" action="search.php">
<select name="country" class="dropdownselect" >
<option value="">Select Country</option>
<option value="Afghanistan" selected="selected">Afghanistan</option>
<option value="Albania" selected="selected">Albania</option>
<option value="Algeria" selected="selected">Algeria</option>
</select>
</form>
And then in search.php;
$country = $country;
+
SQL query for $country..
I need to save DropDown selection to stay selected when someones preform search.
Can it be done with HTML5 storage func?
Thanks in advance
Share edited Oct 8, 2012 at 20:04 Michal Klouda 14.5k7 gold badges56 silver badges79 bronze badges asked Oct 8, 2012 at 19:38 xulxul 2105 silver badges15 bronze badges1 Answer
Reset to default 8Yes, you can store it on select change and then read on page load:
$(document).ready(function() {
var item = window.localStorage.getItem('country');
$('select[name=country]').val(item);
$('select[name=country]').change(function() {
window.localStorage.setItem('country', $(this).val());
});
});
DEMO
本文标签: javascriptHow to save DropDown selection with HTML5 storageStack Overflow
版权声明:本文标题:javascript - How to save DropDown selection with HTML5 storage? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742260972a2442504.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论