JavaScript Answer Example 1
(For Advanced Users Only)

Description:
This reference page contains a basic example of how you can use standard HTML <FORM> components and JavaScripts to create your own custom method of answering TRUE/FALSE questions. In this example, an HTML <FORM> is created with two "radio" buttons. When either of the "radio" buttons is clicked, a JavaScript is called to set the selected answer via the uTestJSI.answerQuestion() API.

Example:

Below is what the example looks like:
True    False

And here is the HTML used to create the radio buttons and the JavaScript to handle when one of the buttons is clicked:
<SCRIPT LANGUAGE="Javascript">
function answerQ0013()
{
   // First get the selected answer from the FORM.
   var answer = "";
   if (document.Q0013.answer[0].checked == true)
   {
      answer = document.Q0013.answer[0].value;
   }
   else
   {
      answer = document.Q0013.answer[1].value;
   }

   // Now set the answer on the answer sheet.
   document.uTestJSI.answerQuestion("13",          <!-- Question Number -->
                                    "TRUE_FALSE",  <!-- Question Type -->
                                    "5",           <!-- Question Points -->
                                    "NONE",        <!-- Question Classification -->
                                    answer);       <!-- Selected Answer -->
}
</SCRIPT>

<FORM NAME="Q0013">
<INPUT TYPE=radio NAME="answer" VALUE="true" onClick="answerQ0013()"> True
<INPUT TYPE=radio NAME="answer" VALUE="false" onClick="answerQ0013()"> False
</FORM>

Note: Don't forget to add the uTestJSI applet to your page too:
<APPLET CODE="uTestJSI.class" CODEBASE="../classes/" NAME="uTestJSI" WIDTH="2" HEIGHT="2">
</APPLET>

More Information:

For more information about creating and using your own HTML FORMs and JavaScripts with uTest, see uTest and JavaScripts.