Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
JavaScript Array of checkboxes 
 

In this Tutorial we want to describe you a code that help you in understanding JavaScript Array of checkboxes. For this we are using JavaScript as Script language.

 

JavaScript Array of checkboxes

                         

In this Tutorial we want to describe you a code that help you in understanding JavaScript Array of checkboxes. For this we are using JavaScript as Script language. In this example we make a HTML form that create two Radio Button., three Check Boxes. and two Radio Button. The validate function is used to validate the form Online Survey. The function validate( ) validates the  form by  if conditional operator. The if condition return you true only when any one of the radio button, check box is selected. In case the user do not select the radio button, check box, the submit button invoke the validate function and show you an alert message.

 

 

 

 

 

Buildingcheckboxes.html

<html>
    <head>
        <title>JavaScript Checkboxes</title>
        <script type="text/javascript">
function validate(form) {
if (!document.form1.sex[0].checked && !document.form1.sex[1].checked){


alert("Please Select Sex")return false;}

var total=""
for(var i=0; i < document.form1.scripts.length; i++){
if(document.form1.scripts[i].checked)
total +=document.form1.scripts[i].value + "\n"
}
if(total==""){
alert("Please select scripts")
}
else
alert ("Checkboxes you have selected are: "+"\n"+total)

return false;
</script>
    </head>
    <body>
        <table border='0' width='50%' cellspacing='0' cellpadding='0' >
            <form name=form1 method=post  onsubmit='return validate(this)'>
                <tr><th colspan="3" align="center">Online Survey<br><br></th>
                </tr>
                
                <tr>
                    <td><b>Sex</b></td>
                    <td>&nbsp;</td>
                    <td>
                        <input type=radio name=sex value='male'>Male <br>
                        <input type=radio name=sex value='female'>Female<br><br>
                    </td>
                </tr>
                
                <tr>
                    <td><b>Skills set</b></td>
                    <td>&nbsp;</td>
                    <td>
                        <input type=checkbox name=scripts value='Java'>Java <br>
                        <input type=checkbox name=scripts value='Jsp'>Jsp<br>
                        <input type=checkbox name=scripts value='Servlets'>Servlets<br>
                        <br>

                    </td>
                </tr>
                
                <tr><td align=center >
                        <input type=submit value=Submit> 
                <input type=reset value=Reset></td></tr>
                
            </form> 
        </table>
    </body>
</html>

Output of the program

Download source code

                         

» View all related tutorials
Related Tags: java javascript c string oop array ant function script object diff fun io include help load variable sed print loop

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.