Sans plus tarder, il suffit de télécharger le code
La copie de code est la suivante:
<% @ Page Language = "C #" AutoEventWireup = "True" CodeBehind = "Web2.aspx.cs" Hérites = "Chapitre2.Web2"%>
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head runat = "server">
<meta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8" />
<Title> </Title>
<script src = "jQuery-1.8.0.js"> </ script>
<script type = "text / javascript">
$ (function () {
$ ("# sub"). Cliquez sur (fonction () {
var str1 = "zhang san:" + $ ("# name"). val ();
var str2 = "Gender:" + $ ('entrée: radio [name = "sex"]: vérifié'). Val ();
var shuzu = [];
$ ('input: checkbox [name = "aihao"]: coché'). chaque (fonction () {// chacun chacun
shuzu.push ($ (this) .val ()); // attribue la valeur au tableau
});
Window.Alert (str1 + '/ n' + str2 + '/ n' + "hôte:" + shuzu);
});
});
</cript>
</ head>
<body>
<form id = "form1" runat = "server">
Nom: <input type = "text" id = "name" /> <br />
Gender: <input type = "radio" id = "nan" name = "sex" checked = "" value = "mâle" /> mâle <input type = "radio" id = "nv" name = "sexe" value = "feme" /> femelle <br />
Hobbies: <entrée type = "coche" /> nager
<input type = "checkbox" name = "aihao" value = "grimpe" /> grimper
<input type = "checkbox" name = "aihao" value = "play ball" /> play ball
<input type = "checkbox" name = "aihao" value = "cyclis" /> cyclisme
<input type = "checkbox" name = "aihao" value = "read" /> read
<input type = "checkbox" name = "aihao" value = "chat" /> chat <br />
<input type = "bouton" id = "sub" value = "sub" /> <input type = "bouton" id = "b" value = "reset" />
</ form>
</docy>
</html>
Le code est très concis, mais il est très pratique. Les amis peuvent le réécrire en fonction des besoins de leur projet et l'utiliser.