Checkbox in a form : CheckBox : Form Control JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Form Control » CheckBox »

 

Checkbox in a form



<html>

<head>
<script type="text/javascript">
    function check(){
        coffee=document.forms[0].coffee
        answer=document.forms[0].answer
        txt=""
        for (i=0;i<coffee.length;++ i){
            if (coffee[i].checked){
                txt=txt + coffee[i].value + " "
            }
        }
        answer.value="You ordered a coffee with " + txt
    }
</script>
</head>

<body>
<form>
How would you like your coffee?<br>
<input type="checkbox" name="coffee" value="cream">With cream<br>
<input type="checkbox" name="coffee" value="sugar">With sugar<br>
<br>
<input type="button" name="test" onclick="check()" value="Send order">
<br>
<input type="text" name="answer" size="50">
</form>
</body>

</html>




           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Form Control
» CheckBox