这个要配合服务器端程序,例如ASP吧:
<input type="checkbox" name="h_game" value="1" <%if str=1 then response.write "checked"%>>
棋牌
<input type="checkbox" name="h_game" value="2"<%if str=2 then response.write "checked"%>>>
游泳
<input type="checkbox" name="h_game" value="3"<%if str=3 then response.write "checked"%>>>
KTV
<input type="checkbox" name="h_game" value="1" <%if str=1 then response.write "checked"%>>
棋牌
<input type="checkbox" name="h_game" value="2"<%if str=2 then response.write "checked"%>>>
游泳
<input type="checkbox" name="h_game" value="3"<%if str=3 then response.write "checked"%>>>
KTV
解决方案 »
- js 对象 setInterval 调用该对象的内部方法并把得到的计时器保存在该对象
- 新手请教一个关于正则贪婪量词和惰性量词的小问题!!
- 关于JS C#互相传值的问题!
- 很郁闷 ,ie下 iframe插入图片问题
- 关于一个 javascript的 获取参数个数的简单问题
- 关于使用javascript write一个fomr 并提交的中文参数乱码问题
- span的问题,请大虾指教
- 有谁知道javascript editor 6.0的注册码啊?
- createPopup创建窗口问题,请帮忙
- window.opener.SetDate(...)是何含义?完整的语法是什么?
- 如何 点标签切换显示不同内容?
- 怎么样获得动态的域值?
int r=0;
for(r=0;r<str.length;r++)
{
%>
arr[<%=r%>]=new Array(str[r]);
<%
}
%>
var ob = document.all.h_game;
for(var j=0;j<ob.length;j++){
if(ob[j].value==arr[j]){
ob[j].checked = true;
}
}
for(i=0;i<arr.length;i++){
for(j=0;j<ob.length;j++){
if(ob[j].value==arr[i]){
ob[j].checked = true;
}
}
其实可以不用数组,只要传一个字符串给客户端就可以了。参见下例:
只要把onload=改成"init('<%=你的字符串%>');"就实现了。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script type="text/javascript">
function init(a){
var ob = document.all.h_game;
for(var j=0;j<ob.length;j++){
if(a.indexOf(ob[j].value)!=-1){
ob[j].checked = true;
}
}
}
</script><body onload="init('1378');">
<input type="checkbox" name="h_game" value="1">棋牌
<input type="checkbox" name="h_game" value="2">游泳
<input type="checkbox" name="h_game" value="3">KTV
<input type="checkbox" name="h_game" value="4">保龄球
<input type="checkbox" name="h_game" value="5">中西餐
<input type="checkbox" name="h_game" value="6">商务中心
<input type="checkbox" name="h_game" value="7">茶秀 咖啡厅
<input type="checkbox" name="h_game" value="8">健身房
<input type="checkbox" name="h_game" value="9">宽带
<input type="button" onclick="init();">
</body>
</html>
youbl(wolf) 的方法用了没效果 但我看着也挺正确的啊 给分~
再次感谢你们2个人啊