You need to sign in to do that
Don't have an account?

Disable set of inputfields using a single checkbox
Hi,
I have the ff code which disable one inputfield when a checkbox is selected. My question is how do i make all the inputfields disabled using the same checkbox. When i tick the checkbox all the inputfield should also be disabled.
<apex:pageBlockSection title="Billing Address" collapsible="false" columns="1">
<apex:inputCheckbox value="{!Lead.Cpy_from_Installation_Address__c}" onchange="document.getElementById('{!$Component.disablefield}').disabled=this.checked"/>
<apex:inputField id="disablefield" value="{!Lead.Billing_House__c}"/>
<apex:inputField id="disablefield2" value="{!Lead.Billing_Apartment__c}"/>
<apex:inputField id="disablefield3" value="{!Lead.Billing_Street__c}"/>
<apex:inputField id="disablefield4" value="{!Lead.Billing_Subdivision__c}"/>
<apex:inputField id="disablefield5" value="{!Lead.Billing_City__c}"/>
<apex:inputField id="disablefield6" value="{!Lead.Billing_Zip_Code__c}"/>
</apex:pageBlockSection>
Thanks,
Del
Hi
Try this
<apex:inputCheckbox value="{!Lead.CostomYesNo__c}" onchange="return confirmDisbaled(this.checked, '{!$Component.disablefield}','{!$Component.disablefield1}','{!$Component.disablefield2}')
'{!$Component.disablefield3}''{!$Component.disablefield4}''{!$Component.disablefield5}';"/>
<apex:form>
<script>
function confirmDisbaled(ifchecked, id ,id1,id2,id3,id4,id5) {
if( ifchecked ) {
document.getElementById(id).disabled = true;
document.getElementById(id1).disabled = true;
document.getElementById(id2).disabled = true;
document.getElementById(id3).disabled = true;
document.getElementById(id4).disabled = true;
document.getElementById(id5).disabled = true;
}
}
</script>
Did this post solve your problem .. If so please mark it solved so that other's get benifited..
Thanks
asish
Hi
If you want to enable and disable simultaneously by clicking checkbox then
simple try this....
<script>
function confirmDisbaled(ifchecked, id ,id1,id2,id3,id4,id5) {
document.getElementById(id).disabled = ifchecked;
document.getElementById(id1).disabled = ifchecked;
document.getElementById(id2).disabled = ifchecked;
document.getElementById(id3).disabled = ifchecked;
document.getElementById(id4).disabled = ifchecked;
document.getElementById(id5).disabled = ifchecked;
}
</script>
Did this post solve your problem .. If so please mark it solved so that other's get benifited..
Thanks
asish
Thanks! however nothing happens to my code. can you help me check plss. :(
========================================
<table width="88%" border="0" bordercolor="#000000" cellSpacing="0">
<tr>
<td width="100%" align="right">
<apex:inputCheckbox value="{!Lead.Cpy_from_Installation_Address__c}"
onchange="return confirmDisabled(this.checked,'{!$Component.a}','{!$Component.b}','{!$Component.c}','{!$Component.d}','{!$Component.e}','{!$Component.f}');"/>
<b><font color="#FF0000">Do you want to copy the billing address from installation address?</font></b>
</td>
</tr>
</table>
<script>
function confirmDisabled(ifchecked,hse,apt,st,subd,city,zip){
if( ifchecked ) {
document.getElementById(a).disabled = true;
document.getElementById(b).disabled = true;
document.getElementById(c).disabled = true;
document.getElementById(d).disabled = true;
document.getElementById(e).disabled = true;
document.getElementById(f).disabled = true;
}}
</script>
<apex:pageBlockSection collapsible="false" columns="2">
<apex:inputField value="{!Lead.Installation_House__c}" required="true"/>
<apex:inputField id="a" value="{!Lead.Billing_House__c}"/>
<apex:inputField value="{!Lead.Installation_Apartment__c}" required="true"/>
<apex:inputField id="b" value="{!Lead.Billing_Apartment__c}"/>
<apex:inputField value="{!Lead.Installation_Street__c}" required="true"/>
<apex:inputField id="c" value="{!Lead.Billing_Street__c}"/>
<apex:inputField value="{!Lead.Installation_Subdivision__c}" required="true"/>
<apex:inputField id="d" value="{!Lead.Billing_Subdivision__c}"/>
<apex:inputField value="{!Lead.Installation_City__c}" required="true"/>
<apex:inputField id="e" value="{!Lead.Billing_City__c}"/>
<apex:inputField value="{!Lead.Installation_Zipcode__c}"/>
<apex:inputField id="f" value="{!Lead.Billing_Zip_Code__c}"/>
</apex:pageBlockSection>
hi
I had checked my code . it was working nice .
Check carefully by giveing alert();
here is my code .It was working nice just check It
<apex:page controller="Checkbokusescontroller">
<apex:form >
<script>
function confirmDisbaled(ifchecked, id1 ,id2,id3)
{
alert(1d1);
document.getElementById(id1).disabled = ifchecked;
document.getElementById(id2).disabled = ifchecked;
document.getElementById(id3).disabled = ifchecked;
}
</script>
<apex:pageBlock >
<apex:pageBlockSection title="Billing Address" collapsible="false" columns="1">
<apex:inputCheckbox value="{!Lead.CostomYesNo__c}" onchange="return confirmDisbaled(this.checked, '{!$Component.disablefield}','{!$Component.disablefield2}','{!$Component.disablefield3}');"/>
<apex:inputField id="disablefield" value="{!Lead.Phone}"/>
<apex:inputField id="disablefield2" value="{!Lead.Title}"/>
<apex:inputField id="disablefield3" value="{!Lead.Fax}"/>
</apex:pageBlockSection> <
/apex:pageBlock>
</apex:form>
</apex:page>..
Just make a customfield CostomYesNo__c in Lead Object ... and create a new page just copy it and paste and see Its working or not....?
Here is my class code...
public class Checkbokusescontroller
{
public Lead Lead {get;set;}
public Checkbokusescontroller()
{
}
}
Thanks
asish