Javascript with Visualforce pages
Javascript is one of key browser technology on Visualforce pages. Javascript provides the framework for communication between other Javascript objects, HTML elements and visualforce controller. This example will explain how can we use javascripts in visualforce pages.
- <apex:page>
- <script>
- function changeFont(input, textid) {
- if(input.checked) document.getElementById(textid).style.fontWeight = "bold";
- else document.getElementById(textid).style.fontWeight = "normal";
- }
- </script>
- <apex:outputPanel layout="block">
- <label for="checkbox">Click this box to change text font: </label>
- <input id="checkbox" type="checkbox"
- onclick="changeFont(this,'{!$Component.thePanel}');"/>
- </apex:outputPanel>
- <apex:outputPanel id="thePanel" layout="block">Change me!
- </apex:outputPanel>
- </apex:page>
No comments:
Post a Comment