Get input from a form, radio button, check box

Source: Internet
Author: User

<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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.