function setCookie(name, value) {
var exp = new Date()
exp.setTime(exp.getTime() + 24 * 60 * 60 * 1000)
document.cookie = name + "=" + escape(value) + "expires=" + exp.toGMTString()
}
function getCookie(name)
{
var regExp = new RegExp("(^| )" + name + "=([^]*)(|$)")
var arr = document.cookie.match(regExp)
if (arr == null) {
return null
}
return unescape(arr[2])
}
</script>
<select id="select_1" onclick="setCookie('select_1',this.selectedIndex)">
<option value="apple">apple</option>
<option value="banana">banana</option>
<option value="cake">cake</option>
</select>
<script type="text/javascript">
var selectedIndex = getCookie("select_1")
if(selectedIndex != null) {
document.getElementById("select_1").selectedIndex = selectedIndex
}
</script>
用JS把选择值存入COOKIE,然后载入页面的时候取出值即可。
后台var sql=“select KeyId as id,class as text from class_grade”
Datatable dt=DBhelper.search(sql,null)
context.Response(dt)
js部分
$.ajaxjson(“后台地址”,“”,function(d){
$(id).combobox(){
data:d,
textfield:'text',
valuefield:'id',
}
})
不好意思,大概如此,我也刚学不久。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)