Thanks akash for sharing this. i'm a web designers. i think it is very helpful for me.
Thanks very very much.![]()
This is a discussion on Creating questions and answers forms for your web pages within the Web Design forums, part of the Web Designing & Development category; Following JavaScript code can help you to easily create Q and A forms for your web pages without using CGI ...
Following JavaScript code can help you to easily create Q and A forms for your web pages without using CGI scripts. You can also make it redirect the visitor to another web page depending on the answer.
following HTML tags to create your quiz formCode:<SCRIPT language="JavaScript" type="text/javascript"> <!-- // // Documentation: // http://chami.com/tips/javascript/ // function checkAnswer(quizForm, theAnswer, urlRight, urlWrong) { var s = "?"; // go through the "current choices" // to find the selected choice. // radio boxes pointing to choices // must be named "cc" // change if necessary // var i = 0; for(;i<quizForm.elements.length;i++) { if(("cc" == quizForm.elements[i].name) && (quizForm.elements[i].checked)) { s = quizForm.elements[i].value; } } // no choice was selected // if("?" == s) { alert("Please make a selection."); return false; } // check if we have the correct // choice selected // if(s == theAnswer) { alert("'"+s+"' is correct!"); if(urlRight) { document.location.href = urlRight; } } else { alert("'"+s+"' is incorrect."); if( urlWrong ) { document.location.href = urlWrong; } } // return "false" to indicate not to // submit the form. // change this to "true" if the form // "action" is valid, // i.e. points to a valid CGI script // return false; } //--> </SCRIPT>
Code:<FORM method="POST" onSubmit="return checkAnswer(this,'B');" > <INPUT TYPE="RADIO" VALUE="A" NAME="cc"> A. Another name for Java<BR> <INPUT TYPE="RADIO" VALUE="B" NAME="cc"> B. A scripting language mostly for the web<BR> <INPUT TYPE="RADIO" VALUE="C" NAME="cc"> C. When you use Java without compiling<BR> <INPUT TYPE="SUBMIT" VALUE="Submit Answer"> </FORM>
Thanks akash for sharing this. i'm a web designers. i think it is very helpful for me.
Thanks very very much.![]()
Last edited by msn90; 06-23-2009 at 10:38 AM.
Bookmarks