Laden Sie den Code ohne weiteres hoch hoch
Die Codekopie lautet wie folgt:
< %@ Page Language = "C#" AutoEventwireUp = "True" codeBehind = "web2.aspx.cs" inherits = "Kapitel2.Web2" %>
<! DocType html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head runat = "server">
<meta http-äquiv = "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 = "Geschlecht:" + $ ('Eingabe: radio [name = "sex"]: checked'). val ();
var shuzu = [];
$ ('Eingabe: checkBox [name = "aihao"]: checked'). jeweils (function () {// jeweils
shuzu.push ($ (this) .val ()); // dem Array Wert zuweisen
});
window.alert (str1 + '/n' + str2 + '/n' + "Host:" + shuzu);
});
});
</script>
</head>
<body>
<Form ID = "Form1" Runat = "Server">
Name: <Eingabe type = "text" id = "name" /> <br />
Geschlecht: <Eingabe type = "radio" id = "nan" name = "sex" checked = "" value = "männlich" /> männlich <Eingabe type = "radio" id = "nv" name = "sex" value = "weiblich" /> weiblich <br />
Hobbys: <Eingabe type = "Kontrollkästchen" /> Schwimmen
<Eingabe type = "CheckBox" name = "aihao" value = "klettern" /> klettern
<Eingabe type = "checkbox" name = "aihao" value = "balle" /> spiele Ball spielen
<Eingabe type = "checkBox" name = "aihao" value = "zyklieren" /> rycling
<Eingabe type = "CheckBox" name = "aihao" value = "lesen" /> lesen
<Eingabe type = "CheckBox" name = "aihao" value = "chat" /> chat <br />
<Eingabe type = "button" id = "sub" value = "sub" /> <Eingabe type = "button" id = "b" value = "reset" />
</form>
</body>
</html>
Der Code ist sehr prägnant, aber sehr praktisch. Freunde können es nach ihren Projektbedürfnissen umschreiben und es verwenden.