Advertisement
FahimFaisal

Javascript_form2

Oct 11th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.88 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/html">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>JS_Form2</title>
  6. </head>
  7. <body>
  8. <script>
  9. function processCB(){
  10.     var boxes=document.check.cb.length;
  11.     var s="";
  12.  
  13.     for(var i=0;i<boxes;i++) {
  14.        if (document.check.cb[i].checked) {
  15.            s = s + document.check.cb[i].value + ",";
  16.        }
  17.    }
  18.        if(s == ""){
  19.            s+="nothing";
  20.        }
  21.        alert("You selected "+s);
  22.  
  23. }
  24. </script>
  25. </body>
  26. <h1>Select your favourite items</h1>
  27. <form name="check">
  28.     &nbsp;<input type="checkbox" name="cb" value="Potato">Potato</input><br/>
  29.  
  30.     &nbsp;<input type="checkbox" name="cb" value="Tomato">Tomato</input><br/>
  31.  
  32.     &nbsp;<input type="checkbox" name="cb" value="Salad">Salad</input><br/>
  33.  
  34.     <br/><input type="button" value="Done" onclick="processCB()"/>
  35. </form>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement