图片预览:
js代码:
<!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=utf-8" />
<title>无标题文档</title>
<style type="text/css">
input{ margin-right:3px}
label{margin:0 5px}
</style>
<script type="text/javascript">
window.onload = function(){
var obox = document.getElementById("box");
var cboList = obox.getElementsByTagName("input");
var oText = document.getElementById("tt");
document.getElementById("box").onclick = function(e){
var src = e?e.target:event.srcElement;
if(src.tagName == "INPUT"){
var values = [];
for(var i=0;i<cboList.length;i++){
if(cboList[i].checked){
values.push(cboList[i].value);
}
}
oText.value = values.join(",");
}
}
}
</script>
</head>
<body>
<p><input type="text" id="tt" /></p>
<div id="box">
<label><input type="checkbox" value="a" />a</label>
<label><input type="checkbox" value="b" />b</label>
<label><input type="checkbox" value="c" />c</label>
<label><input type="checkbox" value="d" />d</label>
<label><input type="checkbox" value="e" />e</label>
<label><input type="checkbox" value="f" />f</label>
</div>
</body>
</html>