Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

How can I get one Submit button to perform three actions?

Avatar

Level 1

I have a 2-page form. One page is completed by an HR person, entering fields that describe a new role, new pay, new hours or a new location for an existing employee. The second page automatically repeats the name, location and job role fields, but also completes the IT requirements linked to the job role (such as whether or not the role needs access to a particular piece of software or not).

The users of the form will have varying degress of IT capability. I wan to enable them to press a single Submit button that does three things: first, print the first page of a two-page form AND e-mail the same page to one e-mail address. Second: e-mail the second page only to a DIFFERENT e-mail address.

I am not a Javascript expert - or even a beginner. Can anyone help? I need to get this ready for Tuesday! Thanks in advance

1 Reply

Avatar

Former Community Member

You will need two buttons on your form to be able to do this.

One is the actual submit button (this will interact with th email system and do the submit). Note that you cannot write programs on a submit button. You will need to make this button invisible to the user. The second button will be a regular button which you can write programs on. Use teh click event of that button. This one will have logic to accomplish the things that you want ...here is some pseudo code to do this:

use print command and one of the parms indicates which pages to print.

Set up the submit button to hold the email address of the person recieving it.

Programmatically click the hidden submit button.

Note that the user will recieve a dialog from the mail client to OK before teh form will be sent.

Set up the submit button to change the email address

Programmatically click the submit button again

User will recieve another dialog to OK the email submission

Also you cannot email part of the form it will have to be the whole form. You coudl get a little more sophisticated and hide parts of the form but the whole form will be sent with the emails. This will need more programming on your part.

Paul