我有一组复选框复选框值页面刷新后检查:组复选框基于URL查询字符串
<input name="LocType" type="checkbox" value="Hospital"/>HOSPITALS  
<input name="LocType" type="checkbox" value="Office"/> PHYSICIAN OFFICES  
<input name="LocType" type="checkbox" value="Emergency"/>EMERGENCY CENTERS  
<input name="LocType" type="checkbox" value="Out-Patient"/>OUT-PATIENT CENTERS  
<input name="LocType" type="checkbox" value="Facility"/>FACILITIES
如下我已经抓住了他们的价值观和传递到URL,可通过重新加载页面后querystring,我想检查任何复选框值传递和设置复选框检查=真。
var url = "http://mysite.com/contact-us/Pages/LocationSearch.aspx?s=bcs_locations&k=";
var checkboxValues = $("input[name=LocType]:checked").map(function() {
return ' '+'bcslocationtype:'+"\"" + $(this).val() + "\"";}).get().join(" OR ");
window.location= url + checkboxValues;
当医院和紧急复选框被选中,并点击搜索,网址如下: http://mysite.com/contact-us/Pages/LocationSearch.aspx?s=bcs_locations&k= bcslocationtype:“医院”或bcslocationtype:“紧急”
现在为什么不工作的事,我不吨看到什么错呢?其insde的document.ready(){}
//Keep the selected chkboxes checked on page redirect
var value = window.location.href.match(/[?&]k=([^&#]+)/) || [];
if (value.length == 2) {
$('input[name=LocType]').each(function (index) {
if(value[1].indexOf($(this).val())>=0)
this.prop("checked", true);
});
}