I am trying to create a radio function where a random question is asked and three radio button answers are presented. When the user selects one of the three answers the other two are grayed out and the third is tested to determine if it is the correct answer. If correct the application is suppose to hide the Q/A div (revealcontent)and present the congratulation (winner)div. If the user answers incorrectly the application is suppose to hide the Q/A div and display the Sorry Wrong Answer (losser)div.
My application is practically working, but when I select the second radio button both the WINNER div is showing and the LOSSER div is showing.
I have been using the Apple Dynamic Forms with DHTML samples from the developer’s connections (
Outlined below is my code I have used PHP5.0, Javascripting and MySQL for the Q/A data:
echo ("<SCRIPT LANGUAGE=\"JavaScript\">\n");
echo ("function validate_question(val) {\n");
echo ("frm=document.forms[0]\n");
echo ("if(val==\"option1\")\n");
echo ("{\n");
echo ("frm.option1.disabled=false;\n");
echo ("frm.option2.disabled=true;\n");
echo ("frm.option3.disabled=true;\n");
echo ("var textString1 = \"$myrow[4]\";\n");
echo ("var textString2 = \"$myrow[7]\";\n");
echo ("}\n");
echo ("if (textString1 == textString2){\n");
echo ("changeObjectVisibility(\"winner1\", \"visible\");\n");
echo ("changeObjectVisibility(\"revealcontent\", \"hidden\");\n");
echo ("}else{\n");
echo ("changeObjectVisibility(\"winner1\", \"hidden\");\n");
echo ("changeObjectVisibility(\"losser1\", \"visible\");\n");
echo ("}\n");
echo ("if(val==\"option2\")\n");
echo ("{\n");
echo ("frm.option1.disabled=true;\n");
echo ("frm.option2.disabled=false;\n");
echo ("frm.option3.disabled=true;\n");
echo ("var textString3 = \"$myrow[5]\";\n");
echo ("var textString4 = \"$myrow[7]\";\n");
echo ("}\n");
echo ("if (textString3 == textString4){\n");
echo ("changeObjectVisibility(\"winner2\", \"visible\");\n");
echo ("changeObjectVisibility(\"revealcontent\", \"hidden\");\n");
echo ("}else{\n");
My application is practically working, but when I select the second radio button both the WINNER div is showing and the LOSSER div is showing.
I have been using the Apple Dynamic Forms with DHTML samples from the developer’s connections (
Outlined below is my code I have used PHP5.0, Javascripting and MySQL for the Q/A data:
echo ("<SCRIPT LANGUAGE=\"JavaScript\">\n");
echo ("function validate_question(val) {\n");
echo ("frm=document.forms[0]\n");
echo ("if(val==\"option1\")\n");
echo ("{\n");
echo ("frm.option1.disabled=false;\n");
echo ("frm.option2.disabled=true;\n");
echo ("frm.option3.disabled=true;\n");
echo ("var textString1 = \"$myrow[4]\";\n");
echo ("var textString2 = \"$myrow[7]\";\n");
echo ("}\n");
echo ("if (textString1 == textString2){\n");
echo ("changeObjectVisibility(\"winner1\", \"visible\");\n");
echo ("changeObjectVisibility(\"revealcontent\", \"hidden\");\n");
echo ("}else{\n");
echo ("changeObjectVisibility(\"winner1\", \"hidden\");\n");
echo ("changeObjectVisibility(\"losser1\", \"visible\");\n");
echo ("}\n");
echo ("if(val==\"option2\")\n");
echo ("{\n");
echo ("frm.option1.disabled=true;\n");
echo ("frm.option2.disabled=false;\n");
echo ("frm.option3.disabled=true;\n");
echo ("var textString3 = \"$myrow[5]\";\n");
echo ("var textString4 = \"$myrow[7]\";\n");
echo ("}\n");
echo ("if (textString3 == textString4){\n");
echo ("changeObjectVisibility(\"winner2\", \"visible\");\n");
echo ("changeObjectVisibility(\"revealcontent\", \"hidden\");\n");
echo ("}else{\n");