function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ganesh RajputGanesh Rajput 

calling javascript from visualforce

<apex:page standardController="RFQ__c" recordSetVar="RFQ"
           lightningStylesheets="true"
           showHeader="false"
           standardStylesheets="false"
           sidebar="false"
           applyHtmlTag="false" applyBodyTag="false"
           docType="html-5.0"
           action="{!genrateRFQQoute}"
           extensions="QuoteCreatorController">
    <apex:form >
        <apex:pageBlock title="Create Quotes" mode="maindetail">
            <center>
                <apex:outputLabel rendered="{!ifSuccess}" style="color:Green"><H3>
               

                          <!-- Calling success toast-->


                </H3></apex:outputLabel>
                <apex:outputLabel rendered="{!ifError}" style="color:red"><H3>
                    

                           <!-- Calling error toast -->


                    </H3></apex:outputLabel>
            </center>
        </apex:pageBlock>
    </apex:form>
    <apex:slds />
    <script>
    function toastSuccess()
    {
        sforce.one.showToast({
            "title": "Success!",
            "key": 'info_alt',
            "type": "success",
            "message": "Sucess message !!!"
        });
    },
        function toastError()
    {
        sforce.one.showToast({
            "title": "Success!",
            "key": 'info_alt',
            "type": "error",
            "message": "Error message !!!"
        });
    }
        
    </script>
    
    
</apex:page>
calling toast functions dynamically 
this visualforce page is added to listview button controller performing mass action, I have to display toast depending on success or failure
 all things are done just need call this script functions.
Best Answer chosen by Ganesh Rajput
{tushar-sharma}{tushar-sharma}
Use Apex:outputpanel instead of apex:outputLabel

All Answers

{tushar-sharma}{tushar-sharma}

<apex:outputLabel rendered="{!ifSuccess}" style="color:Green"><H3>
	<script>toastSuccess();</script>
</H3></apex:outputLabel>
<apex:outputLabel rendered="{!ifError}" style="color:red"><H3>
	<script>toastError();</script>
</H3></apex:outputLabel>
You can call it as normal string method


If this answer helps you, please mark it as accepted.

Regards,
Tushar Sharma
https://newstechnologystuff.com/
Ganesh RajputGanesh Rajput
Thanx for your reply but it not working 
{tushar-sharma}{tushar-sharma}
Use Apex:outputpanel instead of apex:outputLabel
This was selected as the best answer
Ganesh RajputGanesh Rajput
Thanx @Tushar works   


<apex:outputpanel rendered="{!ifSuccess}" style="color:Green">
                    <script>
                    sforce.one.showToast({
                        "title": "Success!",
                        "key": 'info_alt',
                        "type": "success",
                        "message": "Sucess message !!!"
                    });
                    </script>
                </apex:outputpanel>
                <apex:outputpanel rendered="{!ifError}" style="color:red">
                    <script>
                    sforce.one.showToast({
                        "title": "Success!",
                        "key": 'info_alt',
                        "type": "error",
                        "message": "Error message !!!"
                    });
                    </script>
                </apex:outputpanel>