<meta charset= "Utf-8" >
<title>js</title>
<script type= "Text/javascript" >
Function Show () {
var Name=document.myform.name.value;
Alert ("Name:" +name);
var sex;
if (document.myform.sex[0].checked) {
Sex=document.myform.sex[0].value
}else{
Sex=document.myform.sex[1].value
}
Alert ("Gender:" +sex);
var inst= "";
for (i=0;i<document.myform.inst.length;i++) {
if (document.myform.inst[i].checked) {
Inst+=document.myform.inst[i].value+ ",";
}
}
Alert ("Interest:" +inst);
}
</script>
<body>
<form action= "" method= "Post" name= "MyForm" >
Name: <input type= "text" name= "name" ><br>
Gender: <input type= "Radio" name= "Sex" value= "male" checked> male
<input type= "Radio" name= "Sex" value= "women" > Women <br>
Interests: <input type= "checkbox" Name= "Inst" value= "singing" > Singing
<input type= "checkbox" Name= "Inst" value= "swim" > Swim
<input type= "checkbox" Name= "Inst" value= "Dance" > Dance
<input type= "checkbox" Name= "Inst" value= "Programming" checked> programming
<input type= "checkbox" Name= "Inst" value= "Internet" > Internet <br>
<input type= "button" value= "Show" onclick= "Show ()" >
</form>
</body>
Get input from a form, radio button, check box