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 to create a button that performs 2 tasks

Avatar

Former Community Member
I currently have 2 different buttons. One is to print out the form. The other is to submit the form using the HTTP button then we have a php script to take the information. I was wondering if there was a way to combine these two buttons into one?
5 Replies

Avatar

Former Community Member
The submit button is not really a button (in that you cannot add script behind it - there is no click event). From a users perspective you can combine the two functions together so that the user only hits one button. Here is how I would do it:



1. You can programmatically cause the submit button to be pressed by using this command: submit_button_name.execEvent("click")

2. Make the submit button presence - invisible. This will hide the button from the user (so that they cannot press it), but you can still use it to submit programmatically.

3. On the click event of the Print button add the code I mention above.

4. Rename the caption on the print button to something more meaningful like - Submit and Print



Hope that helps

Avatar

Former Community Member
How do I submit the pdf to 4 different emails/people depending on which drop down location is selected (1001, 1002, 1003, 1004) for example.

I have tried using the following:

if firstsite.text=1001

elseif secondbutton.text=1002

elseif thisbutton.text=1003

elseif thisotherbutton.text=1004

elseif anotherbutton.text=1

endif

Thanks for any help!

Avatar

Former Community Member
Assuming the dropdown has options 1,2,3,4 and the submit button is called Button1 you can use code that looks like this:



if (this.rawValue == "1")

Button1.event__click.submit.target = "mailto:user1@adobe.com"



if (this.rawValue == "2")

Button1.event__click.submit.target = "mailto:user2@adobe.com"



if (this.rawValue == "3")

Button1.event__click.submit.target = "mailto:user3@adobe.com"



if (this.rawValue == "4")

Button1.event__click.submit.target = "mailto:user4@adobe.com"

Avatar

Former Community Member
Thank you so much for posting! I just tried that code but it is not working for me. Which event does it go on for the DropDown Box? Is it on "change" that the script needs to go to or something else? Furthermore, is the "...event__click..." written exactly as such with the 2 underlines in between?



I really appreciate your help.



Vee

Avatar

Former Community Member
On the exit event of the drop down is where you should put it. Yes there is an underscore between the event and the click.