더 이상 고민하지 않고 코드를 업로드하십시오
코드 사본은 다음과 같습니다.
< %@ page language = "c#"autoeventwireup = "true"codebehind = "web2.aspx.cs"inherits = "챕터 2.web2" %>
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<Head Runat = "Server">
<meta http-equiv = "content-type"content = "text /html; charset = utf-8" />
<제목> </title>
<script src = "jquery-1.8.0.js"> </script>
<script type = "text/javaScript">
$ (function () {
$ ( "#sub"). 클릭 (function () {
var str1 = "Zhang San :" + $ ( "#name"). val ();
var str2 = "젠더 :" + $ ( 'input : radio [name = "sex"] : checked'). val ();
var shuzu = [];
$ ( 'input : checkbox [name = "aihao"] : checked'). 각 (function () {// 각각
shuzu.push ($ (this) .val ()); // 배열에 값을 할당합니다
});
window.alert (str1 + '/n' + str2 + '/n' + "호스트 :" + shuzu);
});
});
</스크립트>
</head>
<body>
<form id = "form1"runat = "Server">
이름 : <입력 유형 = "text"id = "name" /> <br />
성별 : <입력 유형 = "radio"id = "nan"name = "sex"checked = "value ="male " /> male <입력 유형 ="radio "id ="nv "name ="sex "value ="여성 " /> 여성 <br />
취미 : <입력 유형 = "확인란" /> 수영
<입력 유형 = "checkbox"name = "aihao"value = "등반" /> 등반
<입력 유형 = "checkbox"name = "aihao"value = "Play Ball" /> Play Ball
<입력 유형 = "checkbox"name = "aihao"value = "사이클링" /> 사이클링
<input type = "checkbox"name = "aihao"value = "읽기" /> 읽기
<입력 유형 = "checkbox"name = "aihao"value = "채팅" /> 채팅 <br />
<입력 유형 = "button"id = "sub"value = "sub" /> <입력 유형 = "button"id = "b"value = "Reset" />
</form>
</body>
</html>
코드는 매우 간결하지만 매우 실용적입니다. 친구는 프로젝트 요구에 따라 그것을 다시 작성하여 사용할 수 있습니다.