# How to compute two checkbox values of form and present on Adobe?

I want to show the computation of two values in the questionaire where the user choose one option per question. Many measure proprietary sources of research have PDF documents such as Mielenterveystalo.fi which have such a feature. I am thinking how to accomplish it with LaTeX. The task is the computation (2+2) from checkboxes and then showing the result (4). Expected frontend in Fig. 1. Most potential thread answer about the issue is the answer here with etoolbox package but from 2012 approach so I hope the approach has improved. Code where no checkboxes and gamma box is not a textbox so not accepting input

\documentclass{article}
\usepackage{amssymb}
\usepackage{hyperref}
\begin{document}

\begin{Form}

% TODO make two questions with three checkboxes

% https://tex.stackexchange.com/a/76500/13173
\TextField[maxlen=40,align=2,height=10pt,width=45pt,name=alpha]{Alpha}

\bigskip
\TextField[maxlen=40,align=2,height=10pt,width=45pt,name=beta]{Beta}

\bigskip
\TextField[
maxlen=40,
calculate={%
var f_alpha = this.getField("alpha");
var f_beta = this.getField("beta");
event.value = f_alpha.value + f_beta.value;
},
\end{Form}

% Count core here
Summary score:

\end{document}


Bugs in the code

• does not prevent selection of one or more options. Allow selection two options per question but count the average then. Connect average function then there.

Action: check two places of point (2) in questions (1-2)

Expected output: show value 4 in Summary Score in Adobe Acrobat (acroread in Linux)

Fig. 1 Expected frontend

OS: Debian 9
TeXLive: 2017

• Sorry, but your boxes are anything but no checkboxes that Adobe will recognize with its Form features. You need hyperref for this – user31729 Aug 1 '17 at 15:03
• @Bobyandbob How can you have checkboxes there? – Léo Léopold Hertz 준영 Aug 1 '17 at 16:21
• I think that it could be a strting point for calculations, still now i don't have an answer. – Bobyandbob Aug 1 '17 at 16:26

In order to create radio buttons using hyperref, use the \ChoiceMenu command. Combining this with a custom JavaScript command to populate a text field as demonstrated in the linked answer, we get

\documentclass{article}
\usepackage{hyperref}
\begin{document}

\begin{Form}
\begin{enumerate}

In the above code, the option "Not at all" is preselected using default=0 in order to allow calculations before all questions are answered. If you do not like the selection symbol to appear there from the beginning, change default=0 to default=-0 in order to stop hyperref to automatically select the "Not at all" field, and possibly remove the default value=0 from the \TextField. That way, unanswered questions will contribute with score 0 to the end result.