Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

setAttribute through IF-Statement

Anonymous
Not applicable

Hello

I'm trying to make a form, that picks the recipient depending which value a textfield has (dropdown value -> textfield)

Sounds really simple, hm?

But I'm having huge problems. The programm doesn't seem to like me at all .

//END OF DROPDOWN

<event activity="change">
   <script contentType="application/x-javascript">

   if (
    xfa.event.newText == "Service1" ||
              xfa.event.newText == "Service 2" ||
             xfa.event.newText == "Service 3" ||
              xfa.event.newText == "Service 4" ||

   {
  responsible.rawValue = "Person1"
   }
   else
   {
   responsible.rawValue = "Person2"
   }

   </script>
   </event>

---

<field h="15.0001mm" name="Supervisior" w="97.3mm" x="0.0024mm" y="215.5mm"> 

<event activity="exit">

<script contentType="application/x-javascript">

   if (responsible.rawValue == "Person1")
    {

      document.getElementById('sendmail')[0].setAttribute("target", "mailto:address1@provider.com");

     }
    else
    {
    document.getElementById('sendmail')[0].setAttribute ("target", "mailto:address2@studer.com");
    }
</script>
</event>
</field>

   

<field h="5.9993mm" name="mail2" presence="hidden" w="28.575mm" y="-0.0001mm">

<event activity="click">


<submit format="pdf" id="sendmail" textEncoding="UTF-8"/> // IN HERE I WANT THE TARGET ADDRESS


</event>
</field>


 

Can someone help me with this problem?

Sorry about the code structure, but the syntax highlighting is a bit confusing in this forums.

I hope you can read it

Thanks in advance

Sincerly

Oddy

1 Accepted Solution
Correct answer by
Anonymous
Not applicable

Problem solved. I used the preSubmit event and resolveNode class.

Here's my code, if anyone cares:

<field h="5.891mm" name="mail2" presence="hidden" w="28.5732mm" x="0.1771mm" y="0.1314mm">

     <?templateDesigner isEmailSubmitObject true?>

     <ui>

      <button/>

      </ui>

      <event activity="click">

           <submit format="pdf" textEncoding="UTF-8"/>

      </event>

      <event activity="preSubmit" ref="$form">

       <script contentType="application/x-javascript">

           var vSubmit2 = this.resolveNode("#event.#submit"); // <-- spricht submit-element im event click an

          var antragsteller = Vorname.rawValue + " " + Mitarbeitername.rawValue;

          vSubmit2.format = "pdf";

          var vSubject2 = "Absenz genehmigt";

          mail2.resolveNode("#event.#submit").target = "mailto:" + vEmpfaenger2 + "?subject=" + vSubject2 + "&amp;body=" + "Hallo, bitte diese Absenz noch nachtragen. Danke.";</script>

     </event>

</field>

View solution in original post

1 Reply
Correct answer by
Anonymous
Not applicable

Problem solved. I used the preSubmit event and resolveNode class.

Here's my code, if anyone cares:

<field h="5.891mm" name="mail2" presence="hidden" w="28.5732mm" x="0.1771mm" y="0.1314mm">

     <?templateDesigner isEmailSubmitObject true?>

     <ui>

      <button/>

      </ui>

      <event activity="click">

           <submit format="pdf" textEncoding="UTF-8"/>

      </event>

      <event activity="preSubmit" ref="$form">

       <script contentType="application/x-javascript">

           var vSubmit2 = this.resolveNode("#event.#submit"); // <-- spricht submit-element im event click an

          var antragsteller = Vorname.rawValue + " " + Mitarbeitername.rawValue;

          vSubmit2.format = "pdf";

          var vSubject2 = "Absenz genehmigt";

          mail2.resolveNode("#event.#submit").target = "mailto:" + vEmpfaenger2 + "?subject=" + vSubject2 + "&amp;body=" + "Hallo, bitte diese Absenz noch nachtragen. Danke.";</script>

     </event>

</field>

View solution in original post