1<apex:page standardController="Application__c" extensions="applicationformcontrol" id="pg1" sidebar="false">
2<apex:form id="frm1">
3<!—- To enable or disable the checkbox -->
4<apex:inputField id="check" value="{!app.Checksamepresent__c}" onchange=" return check();"/>
5</apex:form>
6<!-- Javasript functionality-->
7<script>
8<!-- To display or hide the output panel based on the country selection for dependent country picklist or textbox -->
9function check()
10{
11var con=document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.precon}").value;
12var conp=document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.percon}").value;
13if(document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.check}").checked==true)
14{
15if(con=="United States")
16{
17document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p3}").style.display = 'none';
18document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p4}").style.display = 'block';
19else
20{
21document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p3}").style.display = 'none';
22document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p4}").style.display = 'block';
23}
24document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.peradd1}").value=document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.preadd1}").value;
25<!-- Same as Present Address, Permanent Address fields are read only -->
26document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.peradd1}").readOnly=true;
27}
28else
29{
30document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p3}").style.display = 'none';
31document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p4}").style.display = 'block';
32document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.peradd1}").value='';
33document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.peradd1}").readOnly=false;
34}
35}
36<!-- To display or hide, dependent picklist or text box field based on country selection -->
37function change()
38{
39var country=document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.precon}").value;
40if(country=='United States')
41{
42document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.p1}").style.display = 'block';
43document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.p2}").style.display = 'none';
44
45}
46else
47{
48document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.p1}").style.display = 'none';
49document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.p2}").style.display = 'block';
50}
51}
52function change1()
53{
54var country=document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.percon}").value;
55if(country=='United States')
56{
57document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p3}").style.display = 'block';
58document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p4}").style.display = 'none';
59}
60else
61{
62document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p3}").style.display = 'none';
63document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p4}").style.display = 'block';
64}
65}
66</script>
67</apex:page>
68