Tryit Editor v1.4

<html> <head> <script type="text/javascript"> function createOrder() { coffee=document.forms[0].coffee; txt=""; for (i=0;i<coffee.length;++ i) { if (coffee[i].checked) { txt=txt + coffee[i].value + " "; } } document.getElementById("order").value="You ordered a coffee with " + txt; } </script> </head> <body> <p>How would you like your coffee?</p> <form> <input type="checkbox" name="coffee" value="cream">With cream<br /> <input type="checkbox" name="coffee" value="sugar">With sugar<br /> <br /> <input type="button" onclick="createOrder()" value="Send order"> <br /><br /> <input type="text" id="order" size="50"> </form> </body> </html> | Your Result:
Edit the code above and click to see the result. | W3Schools.com - Try it yourself