You need to sign in to do that
Don't have an account?
Kunal Purohit 4
How to display confirmation message after clicking Send button?
Hello Folks,
I want to display a confirmation message "Message Submitted Successfully", with OK button. I am trying but before sending message, it is generating an alert and after that SMS is being sent. Here is my Visualforce page code. Please suggest.
<apex:page showHeader="false" controller="ProspectUserSMSMessageController"> <script language="JavaScript" type="text/javascript"> function ClosePage(){ window.top.close(); } </script> <apex:outputPanel id="redirectionBlock"> <apex:pageMessages /> <script> var hasMessages = '{!hasError}'; if(hasMessages == 'No') { window.top.close(); } </script> <script> function Show_Alert() { var msg = "Message submitted successfully"; alert(msg); } </script> </apex:outputPanel> <apex:form > <apex:pageBlock title="Send SMS" mode="edit"> <apex:pageBlockButtons > <apex:commandButton action="{!sendSMS}" reRender="redirectionBlock" value="Send SMS" onclick="Show_Alert()"/> <apex:commandButton onclick="javascript:ClosePage()" value="Close"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="1" showHeader="false"> <apex:pageBlockSectionItem labelStyle="text-align:right;"> <apex:outputLabel value="Name : " /> <apex:outputLabel value="{!fullName}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Phone No : " /> <apex:outputLabel value="{!phoneNumber}" /> </apex:pageBlockSectionItem> <apex:actionFunction name="displayTemplate" action="{!showContent}" reRender="smsMessage"/> <apex:pageBlockSectionItem > <apex:outputlabel value="Choose Template : " /> <apex:selectList value="{!selectedItem}" size="1" onchange="displayTemplate();"> <apex:selectOptions value="{!templateList}" /> </apex:selectList> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Message : " /> <apex:outputPanel id="smsMessage"> <apex:inputTextArea cols="50" rows="5" value="{!smsMessage}"/> </apex:outputPanel> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Refer the below link to display toast message in VF page.
https://www.eternussolutions.com/2019/04/03/now-toast-your-messages-from-visualforce-pages-too/
If this helps, Please mark it as best answer.
Thanks!!
To display a confirmation message after clicking the Send button, you can use JavaScript's alert() function. Here's how to modify your code:
This way, when the user clicks the Send SMS button, the JavaScript function Show_Alert() will be executed, displaying the confirmation message "Message submitted successfully". The return false; in the onclick event is used to prevent the form from submitting before the alert is displayed.