<html>
<head>
<style type="text/css">
</style>
<script>
window.onload=function(){
document.f.b.onclick=function(){
var buffer=[];
var len=document.f.box.length;
for(var i=0; i<len; i++){
if(document.f.box[i].checked)
buffer.push(document.f.box[i].value);
}
document.f.txt.value=buffer.join(",");
}
}
</script>
</head>
<body>
<form name="f">
<input type="checkbox" name="box" value="aa">aa
<input type="checkbox" name="box" checked value="bb">bb
<input type="checkbox" name="box" value="cc">cc
<input type="checkbox" name="box" value="dd">dd
<input type="button" value="선택된것은?" name="b">
<input type="text" name="txt">
</form>
</body>
</html>
'개발하자 > 자바스크립트' 카테고리의 다른 글
줄추가하기 (0) | 2015.02.28 |
---|---|
createElement 로 셀렉트 옵션 추가하기 (0) | 2015.02.28 |
배열로 접근해서 버튼색바꾸기 document.forms[0].elements[0] (0) | 2015.02.28 |
event.srcElement.tagName (0) | 2015.02.28 |
parentNode,previousSibling,nextSibling (0) | 2015.02.28 |