JavaScript Answer Example 4
(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 ESSAY questions. In this example, an HTML <FORM> is created
with a "textarea" box. Whenever the text in the "textarea" box is changed, a
JavaScript is called to set the selected answer via the uTestJSI.answerQuestion()
API.
|
Example:
Below is what the example looks like:
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 answerQ0016()
{
// First get the text answer from the FORM.
var answer = document.Q0016.answer.value;
// Now set the answer on the answer sheet.
document.uTestJSI.answerQuestion("16", <!-- Question Number -->
"ESSAY", <!-- Question Type -->
"5", <!-- Question Points -->
"NONE", <!-- Question Classification -->
answer); <!-- Specified Text -->
}
</SCRIPT>
<FORM NAME="Q0016">
Please complete the essay below:
<BR>
<TEXTAREA NAME="answer" WRAP=SOFT ROWS=10 COLS=45 onChange="answerQ0016()"></TEXTAREA>
</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.
|
|