I have a panel that display a text box and a check box. AIM1: I want to grayed out input field if check box is selected. And when page is loaded both should be open to use but once selected either one, other should clear its selection and gray out.
I tired Javascript/jquery nothing is working. I am not understanding why.
<apex:panelGrid columns="5" id="theGrid" width="80%">
<apex:outputLabel > A </apex:outputLabel>
<apex:inputfield id="idAText" value="{!ttlookup.a}" />
<apex:inputCheckbox id="checkBoxAId" value="{!Acheckbox}" onchange="tt(this);"/>
<apex:outputLabel > </apex:outputLabel>
<apex:outputLabel > Check </apex:outputLabel>
<apex:outputLabel >B </apex:outputLabel>
<apex:inputfield id="idRMText" value="{!ttlookup.B}" />
<apex:inputCheckbox id="checkBoxBId" value="{!Bcheckbox}"/>
<apex:outputLabel > </apex:outputLabel>
<apex:outputLabel > Check </apex:outputLabel>
<apex:outputLabel > B </apex:outputLabel>
<apex:inputfield id="idRMText" value="{!ttlookup.B}" />
<apex:inputCheckbox id="checkBoxBId" value="{!Bcheckbox}"/>
<apex:outputLabel > </apex:outputLabel>
<apex:outputLabel > Check </apex:outputLabel>
</apex:panelGrid>
<script type="text/javascript">
function tt(chkboxCtrl) {
var Aid = $("[id*=checkBoxAId]").is(':checked');
alert(Aid);
try {
if( chkboxCtrl.checked ) {
$("[id*=idAText").style.display = 'none';
}
else {
$("[id*=idAText").style.display = 'inline';
}
}
catch(e) {
alert(e);
}
}
</script>
if i can change this
if( chkboxCtrl.checked ) {
$("[id*=idAText").css("display", "none");
}else {
$("[id*=idAText").css("display", "block");
}
see below images


apex:inputCheckbox,onchangeevent handler remove{!}. Eg.onchange="toggledDisplay();"$( document ).ready(function() { //your js function });