These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Calculating Values to creat a quiz

danlabranche
Registered: Jan 17 2009
Posts: 19

On my page I have an image with 10 drop down boxes next to specific organs within the image. Each drop down has the same 10 answers but only one is correct per item that it points to. Is there a way to add a value and have a button to calculate how many answers were correct?
This is for educational/study purposes, if you can help you will be helping A&P students at the Manchester Community College. Thank you!

My Product Information:
Acrobat Standard 7.0
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Yes, there are a number of ways you could accomplish this, but you'll have to provide a bit more information. How have you set up the combo boxes? What are there names, and of you set up export values for each item, what are they? I would suggest setting up export values to make it easy to determine through code whether the answer is correct. For example, something like:

Combo box items

Item        Export value---------------------------Brain          wrong1

Lung correct

Heart wrong2

Liver wrong3

Spleen wrong4

Pancreas wrong4

Kidney wrong5

Bladder wrong6

Kneecap wrong7

Toe wrong8

---------------------------

The export value for each wrong answer has to be unique, so that's why they each have a number suffix.

Now, in the button's Mouse Up event you could check the value of each of the combo boxes and count up how many are correct. The JavaScript code might look like:

// Initialize the count variablevar num_correct = 0; // Loop through the combo boxes and the count correct answersfor (var i = 0; i < 10; i += 1) {if (getField("combo." + i).value === "correct") num_correct += 1;} // Tell the user how many are correctapp.alert("You have chosen " + num_correct + " correct answers.", 3);

This code assumes you've named your combo boxes "combo.0", "combo.1", ..., "combo.9". It is also fairly bare-bones, and does not take into account items that have not been answered, but I hope you'll get the general idea of how this can be done. If you have more questions, post again.

George
lkassuba
ExpertTeam
Registered: Jun 28 2007
Posts: 3636
George, how would you suggest doing this if the form is created in Designer not Acrobat?

Lori Kassuba is an AUC Expert and Community Manager for AcrobatUsers.com.