Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

Form that totals correct answers How To

Hi all,

I would like to create a form in FP2003 that will allow users to input values to a sum, then when they are complete taking the quiz click on the Check button. Beside this button a box will display how many of the sums they got correct.

I played around and set the validation options in the text box area to look for a specific value, but dont know how to incorporate this into the total Correct box.

Thanks for your help in advance guys.

Kevin
<!--webbot bot="Validation" S-Data-Type="Number" S-Number-Separators=",." S-Validation-Constraint="Equal to" S-Validation-Value="3025" -->
 
 
As an example of what I did to set validation for the sum 55 X 55

Open in new window

0
oconnork00
Asked:
oconnork00
1 Solution
 
brundoCommented:
Hi,

there are two problems with validation:
- it validates only if the result is correct, but doesn't add the points for your quiz
- you don't see the script which will validate your field content until publishing
  (this is what the webbot from your code snippet does).

So, you have to write your script. Let us assume you users have JavaScript enabled
(what the majority, but not all users have).

Below is the page with script - you can create a new page and copy the whole
content in your code view instead of generated content. Then show the page in
browser and test it by entering new values.

There is a lot of place for improvement, but I would first check the idea is good for you.

If it is ok, try to read and understand the script... then, try to make a new addition
exercise with new numbers. If it is ok, then you should define what you need and solve
problem by problem. Or ask further :-))
<html>
 
<head>
<title>Addition test</title>
 
<script language="javascript" type="text/javascript">
 
	points = 0;
	
	function check (field,number) {
	
	   tmpelement = document.getElementById("T" + field);
	   tmpelement.disabled = true;
	   
	   if (tmpelement.value == number) {
	   
	   		tmpelement = document.getElementById("points");
	   		points += 1;
	        tmpelement.value = points;
	        
	        tmpelement = document.getElementById("R" + field);
	   		tmpelement.value = ":-))";
	   		
	   } else {
	   
	        tmpelement = document.getElementById("R" + field);
	   		tmpelement.value = ":-((";   
	   		
	   }
	}
</script>
 
</head>
 
<body>
 
<form name="test" method="POST" action="maybeSomeActionAfterTheQuiz;">
	<blockquote>
 
		<p>5 + 1 = 
		   <input type="text" id="T1" size="5" onchange="check(1,5+1);"> 
		   <input type="text" id="R1" size="5" disabled="true"></p>
		<p>5 + 3 = 
		   <input type="text" id="T2" size="5" onchange="check(2,5+3);"> 
		   <input type="text" id="R2" size="5" disabled="true"></p>
 
		<p>Total: <input type="text" id="points" size="5" disabled="true" value="0"></p>
 
	</blockquote>
</form>
</body>
 
</html>

Open in new window

0
 
oconnork00Author Commented:
Hi Brundo,

Exactly what I was looking for, thank you.

Kevin
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now