InterviewSolution
| 1. |
How Can You Access Visualforce Components Values Into A Javascript? |
|
Answer» Using Component GLOBAL variable, we can ACCESS visualforce COMPONENTS in javascript. Let us suppose, we want to use id of an apex field with id=”afield”. So, we can use the {!$Component.afield} SYNTAX to use PROPERTIES of the field in javascript. Let us suppose, we want to store the field’s value in java script, then we can use like below: <script> Var a =’ document.getElementById('{!$component.afield}').value’; </script> Using Component global variable, we can access visualforce components in javascript. Let us suppose, we want to use id of an apex field with id=”afield”. So, we can use the {!$Component.afield} syntax to use properties of the field in javascript. Let us suppose, we want to store the field’s value in java script, then we can use like below: <script> Var a =’ document.getElementById('{!$component.afield}').value’; </script> |
|