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

radio button survey

lajj
Registered: Jul 30 2008
Posts: 13

Hi.
I have to do a multiple pages survey document.
each question have a A/B/C/D choice, where each letter have a radio button, corresponding to a value. (A=1, B=2, etc, you got the point)
This, I can do and its ok.

But, I want the user to click a "finished" button before the the results (sum of all button) are returned in a text field. plus, I want the user to go trough all the questions before he can view the results.
This I cant do...

Anybody have a way to do this? or where do I have to look to complete my Acrobat Jedi training?
many thanks

My Product Information:
Acrobat Pro 8.0, Macintosh
lajj
Registered: Jul 30 2008
Posts: 13
oh and the results are supposed to be read by the user, no server stuff and whatnot :)
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Yes, but you will have code the JavaScript for the button. And in that coding you will have to track to see if there are any radio buttons or check boxes with an "Off" value (no selection made) and sum the non-Off buttons. After all the fields have been checked you will need to issue an appropriate message and not display the total or display the total.

George Kaiser

lajj
Registered: Jul 30 2008
Posts: 13
all right !
So I have to code in my "finish button" right ?
any hint on where I could find that javascript, or an example ?

thanks alot
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
For 2 check boxes named "cb1" and "cb2" with the sum field being called "Score", one could code for the "Mouse Up" action for the 'finidhed" button:

// array of field names for responses
var aSelections = new Array('cb1', 'cb2');
// variable to track if all response fields answered. assume true
var bAllAnswered = true;
// sum of answered fields' values
var fSum = 0;
// clear sum field
this.getField('Score').value = '';
// loop through the questionnaire fields
for(i = 0; i < aSelections.length; i++) {
// if i field "Off" not all fields answered
if(this.getField(aSelections[i]).value == "Off") bAllAnswered = false;
else fSum = fSum + Number(this.getField(aSelections[i]).value); // sum field values
}
if(bAllAnswered) this.getField('Score').value = fSum;
else app.alert('All questions need to be answered', 1, 0);

George Kaiser

lajj
Registered: Jul 30 2008
Posts: 13
thank you soooo much !!!!

This is great, it works perfectly !

Thank you again and have a great day !