AttributionsTogether: 1 IDependOn-Set: 1 IDependOn-Set: 102 IDependOn-Set: 109 IDependOn-Set: 110 IDependOn-Set: 115 IDependOn-Set: 98 LastModifiedSecs: 1006808081 Parent: 102 SequenceNumber: 4 Title: checkbox.js Part: 0 Author-Set: sauer@cloudmaster.com LastModifiedSecs: 1006808049 Type: Lines: 1 Simple script to check a checkbox-based form and redirect to one of 3 pages, depending on the selected values. The only requirement is that the checkboxes have a value of '0' (or something else false) if they should be unchecked and a value of '1' if they should be checked. EndPart: 0 Part: 1 Author-Set: sauer@cloudmaster.com LastModifiedSecs: 1006808069 Type: Lines: 1 http://www.cloudmaster.com/~sauer/demos/checkbox.js EndPart: 1 Part: 2 Author-Set: sauer@cloudmaster.com LastModifiedSecs: 1006808081 Type: monospaced Lines: 49 function checkstuff(daForm){ // set these to the forwarded-to pages var allright = "378_io_al-mp1_5.1.1.htm"; var somewrong = "378_io_al-mp1_5.1.2.htm"; // total number of right answers var numright = 5; // some alert texts var alert_toofew = "Please select " + numright + " answers."; var alert_toomany = "Please select " + numright + " answers."; var alert_none = "Please select something."; // stuff below here should remain unchanged var numchecked = 0; var gotright = false; var gotwrong = false; for(i=0; i numright){ // too many checked: alert(alert_toomany); }if(numchecked > 0){ // checked some if((gotright && !gotwrong) || (!gotright && gotwrong)){ // marked some right and none wrong or // marked some wrong and none right alert(alert_toofew); }else if(gotwrong && gotright){ // marked some right and some wrong document.location = somewrong; } }else{ // marked none. alert(alert_none); } } EndPart: 2