How to Call a JavaScript Function from Command Button in Visualforce Page?

Sample Code:


Visualforce Page :

<apex:page >

<script>
    function show(){
        alert('Test');
    }
</script>

<apex:form >
    <apex:pageBlock >
        <apex:pageBlockButtons >            
            <apex:commandButton value="Call JavaScript" onclick="show();"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>

</apex:page>

0 Comments