Magic cards

Select a random number from card number one, and check the boxes of the card that contain the number you chose, including card number one.

by Amando Filipe

HTML

<form name="myform">
    <img src="http://imgur.com/IPS2h.png"><br/>
    <input name="mybox" type="checkbox" value="1" ><br/>
    <img src="http://imgur.com/UqdS9.png"><br/>
    <input name="mybox" type="checkbox" value="2" ><br/>
    <img src="http://imgur.com/Vp2O6.png"><br/>
    <input name="mybox" type="checkbox" value="4" ><br/>
    <img src="http://imgur.com/d4mUO.png"><br/>
    <input name="mybox" type="checkbox" value="8" ><br/>
    <img src="http://imgur.com/pEufc.png"><br/>
    <input name="mybox" type="checkbox" value="16" ><br/>
    <img src="http://imgur.com/D5KrA.png"><br/>
    <input name="mybox" type="checkbox" value="32" ><br/>
    <input type="button" value="check number" onClick="shownum()">
</form>

JavaScript

function shownum() {
    num = 0;
    for (i = 0; i < myform.length; i++) {
        if (document.myform.mybox[i].checked === true) {
            num += document.myform.mybox[i].value;
        } else {
            num += 0;
        }
    }
    alert(num);
}