2

I want to have some TextFields in my form where one can put numbers (shares) and the last TextField should be 100 - the sum of all other TextFields. I found this but it did not help, nothing happens. I do not know where the problem is.

My code is the following:

\documentclass[a4paper,10pt, hidelinks]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[margin=1.5cm]{geometry} 
\usepackage{tabularx}

\usepackage{makecell,
  tabularx}           
\setcellgapes{3pt}
\usepackage{enumitem}

\usepackage{hyperref} 


\begin{document}

\begin{Form}

\subsection{Welchen Anteil in \% (geschätzt) haben folgende Bereiche:}

\begin{itemize}[itemsep=4pt]

\item \TextField[name = anteilquali]{Qualitätsmanagement:}\\
\item \TextField[name = anteildaten]{Datenschutz:}\\
\item \TextField[name = anteilorga]{Organisation:}\\
\item \TextField[name = anteilfinanzen]{Finanzen:}\\
\item \TextField[name = anteiloeffentlich]{Öffentlichkeitsarbeit:}\\
\item \TextField[name = anteilsonstige, readonly = true, calculate={%
    event.value = 100 - 
    (this.getField("anteilquali").value +
    this.getField("anteildaten").value + 
    this.getField("anteilorga").value + 
    this.getField("anteilfinanzen").value + 
    this.getField("anteiloeffentlich").value); 
  }]{Sonstiges:}

\end{itemize}

\end{Form}

\end{document}
2

\usepackage[ngerman]{babel} turns double-quotes into active characters which blow up the JavaScript code embedded in the PDF output. If they are replaced with single quotes, ', the code remains intact. Also, it might be useful to provide the text fields with initial values:

\documentclass[a4paper,10pt, hidelinks]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[margin=1.5cm]{geometry} 
\usepackage{tabularx}

\usepackage{makecell,
  tabularx}           
\setcellgapes{3pt}
\usepackage{enumitem}

\usepackage{hyperref} 


\begin{document}

\begin{Form}

\subsection{Welchen Anteil in \% (geschätzt) haben folgende Bereiche:}

\begin{itemize}[itemsep=4pt]

\item \TextField[name = anteilquali,value=0]{Qualitätsmanagement:}\\
\item \TextField[name = anteildaten,value=0]{Datenschutz:}\\
\item \TextField[name = anteilorga,value=0]{Organisation:}\\
\item \TextField[name = anteilfinanzen,value=0]{Finanzen:}\\
\item \TextField[name = anteiloeffentlich,value=0]{Öffentlichkeitsarbeit:}\\
\item \TextField[name = anteilsonstige,value=100,readonly = true,calculate={%
    event.value=100 - (
    this.getField('anteilquali').value + 
    this.getField('anteildaten').value +  
    this.getField('anteilorga').value +  
    this.getField('anteilfinanzen').value +  
    this.getField('anteiloeffentlich').value); 
  }]{Sonstiges:}

\end{itemize}

\end{Form}

\end{document}
  • Great, thank you so much! – TobiSonne May 21 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.