Sin más preámbulos, simplemente cargue el código
La copia del código es la siguiente:
< %@ Página lenguaje = "C#" AutoeventWireUp = "True" CodeBeHind = "Web2.aspx.cs" heredes = "Capítulo2.Web2" %>
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head runat = "servidor">
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> </title>
<script src = "jQuery-1.8.0.js"> </script>
<script type = "text/javaScript">
$ (function () {
$ ("#sub"). Click (function () {
var str1 = "zhang san:" + $ ("#name"). val ();
var str2 = "género:" + $ ('input: radio [name = "sexo"]: checked'). val ();
var shuzu = [];
$ ('Input: CheckBox [name = "aihao"]: checked'). Cada (function () {// cada uno
shuzu.push ($ (this) .val ()); // Asignar valor a la matriz
});
Window.alert (str1 + '/n' + str2 + '/n' + "host:" + shuzu);
});
});
</script>
</ablo>
<Body>
<Form ID = "form1" runat = "servidor">
Nombre: <input type = "text" id = "name" /> <br />
Género: <input type = "radio" id = "nan" name = "sex" checked = "" value = "masculino" /> macho <input type = "radio" id = "nv" name = "sex" valor = "femenino" /> mujer <Br />
Pasatiempos: <input type = "Checkbox" /> Natación
<input type = "checkbox" name = "aihao" value = "escalando" /> escalada
<input type = "checkbox" name = "aihao" value = "Play Ball" /> Play Ball
<input type = "checkbox" name = "aihao" value = "ciclismo" /> ciclismo
<input type = "checkbox" name = "aihao" value = "read" /> leer
<input type = "checkbox" name = "aihao" value = "chat" /> chat <br />
<input type = "botón" id = "sub" value = "sub" /> <input type = "botón" id = "b" value = "restablecer" />
</form>
</body>
</html>
El código es muy conciso, pero es muy práctico. Los amigos pueden reescribirlo de acuerdo con las necesidades de su proyecto y usarlo.