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.

Differentiating between 2 Submit Buttons on 1 template(xdp)?

Avatar

Former Community Member
I would like my Template(xdp) to contain 2 submit buttons.



Button 1 - Directly submits form



Button 2 - Displays popup that allows user to modify dynamic data and then directly submits form.



How do I differentiate between the 2 buttons so that they get the popup only when the user clicks Button 2?



Is there an easy way to do this? I feel like I'm missing something simple here..



Thanks in advance,



Bob
2 Replies

Avatar

Former Community Member
I have 2 submit buttons -> "btnSubmit" and "btnModify"



I placed the following JavaScript in the preSubmit() event, so that when the "btnModify" button is clicked the user will first get prompted with a dialog, and then the form submits. When the user clicks the "btnSubmit" button they are not prompted with the dialog.



if(xfa.event.target.name == "btnModify"){

commonFunctions.showDialogReopenDecline();

}



Is there a more elegant way of executing this logic?



Thanks



Bob

Avatar

Level 6
I have another way, but I'm not sure whether I'd say that it's more elegant.



Create a submit button "btnRealSubmit" with no script on it. Set its presence to "invisible". Make btnModify and btnSubmit normal command buttons. On the click event for these, you can write whatever script you want including presenting warning dialogs and so on. When you want to submit, call btnRealSubmit.execEvent("click");



Jared Langdon

www.jlangdon.ca