4

I would like to retrieve a hyperref TextField's value for later use in an email submit. As an example: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

\usepackage{hyperref}

\newdimen\longline

\def\LayoutTextField#1#2{#2} % override default in hyperref
\def\lbl#1{\hbox to 4cm{#1\dotfill\strut}}%
\def\labelline#1#2{\lbl{#1}\vbox{\hbox{\TextField[name=#1,width=#2]{\null}}\kern2pt\hrule}}

\def\q#1{\hbox to \hsize{\labelline{#1}{\longline}}\vskip1.4ex}
\def\DefaultWidthofChoiceMenu{12pt}%
\longline=0.95\textwidth\advance\longline-6em
\newcommand{\hgt}{17\baselineskip}

\newcommand{\nameRUID}{
    \TextField[name = Name,
        width = 7cm,
        borderwidth = 0,
        bordersep = 1pt,
        backgroundcolor = {.85 .85 .85}]
        {Name}
        \hskip1ex
    %%
    \TextField[name = RUID,
        width = 2.5cm,
        borderwidth = 0,
        bordersep = 4pt,
        backgroundcolor = {.85 .85 .85}]
        {RUID}
        \vskip1ex
}

\begin{document}

\renewcommand*{\DefaultHeightofTextMultiline}{6\baselineskip} 
\renewcommand*{\LayoutTextField}[2]{\makebox[3.5em][l]{#1:}%
  \raisebox{\baselineskip}{\raisebox{-\height}{#2}}}

\begin{Form}[action = mailto:forms <walt@dataanalyticscorp.com>?subject = Midterm Exam for this.getField('Name').value, method = get ]

    \nameRUID

    \fcolorbox{black}{yellow}{
            \mypar
            \begin{boxedminipage}{6in}
                \begin{center}
                    {\LARGE \textbf{Click this Button to Submit Your Exam}}
                    \par\bigskip
                    {\Large Rename this pdf file to your Last Name and RUID BEFORE submitting.  Example: Smith\_1234.pdf}
                    \par\bigskip
                    \Submit[export=pdf]{{\large \textbf{Submit}}}
                    \par\bigskip
                \end{center}    
            \end{boxedminipage}
        }
\end{Form}

\newpage

\end{document}

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

I want the Name entry from the \nameRUID command to be used in the email submit. But I cannot figure out how to make this work. Any advice?

Thanks,

Walt

2
+150

I am not familiar with javascript but here is an idea found here. What we need is to create a \PushButton with the option onclick.

\documentclass[french]{article}
\usepackage{xcolor}
\usepackage{hyperref}

\newdimen\longline

\def\LayoutTextField#1#2{#2} % override default in hyperref
\def\lbl#1{\hbox to 4cm{#1\dotfill\strut}}%
\def\labelline#1#2{\lbl{#1}\vbox{\hbox{\TextField[name=#1,width=#2]{\null}}\kern2pt\hrule}}

\def\q#1{\hbox to \hsize{\labelline{#1}{\longline}}\vskip1.4ex}
\def\DefaultWidthofChoiceMenu{12pt}%
\longline=0.95\textwidth\advance\longline-6em
\newcommand{\hgt}{17\baselineskip}

\newcommand{\nameRUID}{
    \TextField[name = Name,
        width = 7cm,
        borderwidth = 0,
        bordersep = 1pt,
        backgroundcolor = {.85 .85 .85}]
        {Name}
        \hskip1ex
    %%
    \TextField[name = RUID,
        width = 2.5cm,
        borderwidth = 0,
        bordersep = 4pt,
        backgroundcolor = {.85 .85 .85}]
        {RUID}
        \vskip1ex
}

\begin{document}

\renewcommand*{\DefaultHeightofTextMultiline}{6\baselineskip} 
\renewcommand*{\LayoutTextField}[2]{\makebox[3.5em][l]{#1:}%
  \raisebox{\baselineskip}{\raisebox{-\height}{#2}}}

\begin{Form}

    \nameRUID

    \fcolorbox{black}{yellow}{%
            \begin{minipage}{6in}
                \begin{center}
                    {\LARGE \textbf{Click this Button to Submit Your Exam}}
                    \par\bigskip
                    {\Large Rename this pdf file to your Last Name and RUID BEFORE submitting.  Example: Smith\_1234.pdf}
                    \par\bigskip
                   % \Submit{{\large \textbf{Submit}}}
                   \PushButton[
                        onclick={var TheSubject = "Midterm Exam for " + this.getField("Name").value; 
                        var mymailto = "mailto:forms <walt@dataanalyticscorp.com>?subject=" + TheSubject; 
                        this.submitForm({cURL: mymailto, cSubmitAs: "PDF" });}]{{\large \textbf{Submit}}}
                    \par\bigskip
                \end{center}    
            \end{minipage}}
\end{Form}

\newpage

\end{document}

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.