LOADING
1
5883
all
1185
select
1038
and
864
sql
643
FROM
438
-
405
LOGIN
JOIN
MAILL
ENJOYSITE
Business
Business
Information
Information
Study
IONIC
REACT
PHP
GNU
MySQL
ASP
.NET
MsSQL
Html
CSS
Script
SEO
DNS
JQuery
Eng
book
book
free
free
:: 글답변 ::
이 름
패스워드
이메일
홈페이지
옵 션
html
분 류
선택하세요
Html
CSS
Script
JQuery
ASP
PHP
GNU
.NET
MySQL
MsSQL
DNS
SEO
ENG
IONIC
REACT
제 목
> > > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> > <html> > <head> > <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> > <title>Insert title here</title> > <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script> > <script type="text/javascript"> > > $(document).ready(function() { > // 체크 박스 모두 체크 > $("#checkAll").click(function() { > $("input[name=box]:checkbox").each(function() { > $(this).attr("checked", true); > }); > }); > > // 체크 박스 모두 해제 > $("#uncheckAll").click(function() { > $("input[name=box]:checkbox").each(function() { > $(this).attr("checked", false); > }); > }); > > // 체크 되어 있는 값 추출 > $("#getCheckedAll").click(function() { > $("input[name=box]:checked").each(function() { > var test = $(this).val(); > console.log(test); > }); > }); > > // 서버에서 받아온 데이터 체크하기 (콤마로 받아온 경우) > > $("#updateChecked").click(function() { > var splitCode = $("#splitCode").val().split(","); > for (var idx in splitCode) { > $("input[name=box][value=" + splitCode[idx] + "]").attr("checked", true); > } > }); > > // test case > test1(); > }); > > function test1() { > console.log("################################################"); > console.log("## test1 START"); > console.log("################################################"); > var cnt = $("input:checkbox").size(); > console.log("checkboxSize=" + cnt); > $("input[name=box]:checkbox").each(function() { > var checkboxValue = $(this).val(); > console.log("checkboxValue=" + checkboxValue); > }); > console.log("----------------------------------------------"); > $("#checkboxArea").children().each(function() { > var checkboxValue = $(this).children(":checkbox").val(); > var text = $(this).children().eq(1).text(); > console.log(text + "=" + checkboxValue); > }); > } > > </script> > </head> > <body> > > <div id="checkboxArea"> > <li><input type="checkbox" name="box" value="A" /><label>1번째 checkbox</label></li> > <li><input type="checkbox" name="box" value="B" /><label>2번째 checkbox</label></li> > <li><input type="checkbox" name="box" value="C" /><label>3번째 checkbox</label></li> > <li><input type="checkbox" name="box" value="D" /><label>4번째 checkbox</label></li> > </div> > > <br/><br/> > > <div id="buttonGroups"> > <input type="button" id="checkAll" value="check all" /> > <input type="button" id="uncheckAll" value="uncheck all" /> > <input type="button" id="getCheckedAll" value="get checked all" /> > <input type="button" id="updateChecked" value="updateChecked" /> > </div> > > <input type="hidden" id="splitCode" name="splitCode" value="A,C,D" /> > </body> > > </html> > > > <!-- > 작성자 주석 : 한 가지 고민스러운 것은 서버에서 받아온 데이터가 콤마가 아닌 리스트 형태일 경우 어떻게 처리하는 것이 좋을까 이다. > service layer에서 리스트 형태의 checkbox 데이터를 콤마 형태로 가공한 후 view에 던져줘야 할까? > 아니면 리스트로 받은 데이터를 view에 던져주어 데이터 가공 작업을 위임할까? > --> >
링크 #1
링크 #2
파일첨부
왼쪽의 글자를 입력하세요.
inbanner118x33
inbanner118x33
inbanner118x33
inbanner118x33
inbanner118x33
inbanner118x33
inbanner118x33
COPYRIGHT©
BYWOONG
ALLRIGHTSRESERVED
경영
|
프로그래밍
|
외국어
|
정보게시판
|
자유게시판
|
포트폴리오
|
내소개
|
|
로그인
|
회원가입
Page loading took : 1785687340 seconds