Hi,
Sounds like quite a task to undertake.
First you would need to have the questions and answers stored in the form, probably in hidden fields. I would suggest a table, first column the question, second column the answer.
What i would do is create a random number generator, it needs a button for the script and a numeric field (which will be hidden)
form1.#subform[0].Button1::click - (JavaScript, client)
//random number between 1 and 26
var myRN = Math.random(); //create a variable for the random code
var lower = 1; //this is the lowest 'question answer table row number'
var upper = 26; //this is the highest ''question answer table row number'
NumericField1.rawValue = Math.floor(myRN*(upper - lower)) + lower; // show random number in numeric field
After generating the number you will then need to use logic to show the question and answer based on the random number. Something like:
if(NumericField1.rawValue == "3") //if the random number is 3, execute the code
{
//show the question and answer in row 3 in the textfields that are visible to the user.
question1TextField.rawValue = qaTable.Row3.question.rawValue;
answer1TextField.rawValue = qaTable.Row3.answer.rawValue;
}
In my example:
NumericField1 is the random number object
question1TextField is the first visible text field to show the question
answer1TextField is the first visible answer field to show the answer
qaTable is the name of the hidden table storing the questions and answers
Row3.question - question is a textField on Row3 of the table holding the question
Row3.answer - answer is a textField on Row3 of the table holding the answer
Here is a start for you, there are many considerations to look at.
• If you are wanting to show 4 questions and answers with one click, it is possible that your random number might show the same number and you will have the questions and answers repeated.
• To show 4 items at once, you probably need 4 random numbers generated.
• You will need to add more logic to test if a textfield is empty or not. Meaning, in my code, i just sent the question and answer to the first visible text fields, you need to add logic so that if the first textfield is not empty, it will place the question and answer in the next text field...and so on. If you do use 4 random generators and the first field is not empty, you could then use random generator 2 etc
I hope this helps to give you something to go on.