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

On clicking checkbox related panel has to be displayed
Onclicking the checkbox related question has to display, i have out only two questions in data as of now.
On clicking the checkbox it is returing the correct Id and I am setting the id to show() but the panel is not displaying.
Can someone please look at the code
Controller
public class ProposalManagementController{
private list <Quoting_Tool_Questions__c> qlist;
public list <ProposalManagementWrapper> wrapperlist;
public ProposalManagementController(){}
public list <ProposalManagementWrapper> getQuestions(){
try{
wrapperlist = new list <ProposalManagementWrapper> ();
qlist = [select id,name,Question__c,Question_Order__c,Section_Name__c,Section_Order__c,Key__c,Dependent_Question__c from Quoting_Tool_Questions__c ORDER BY Question_Order__c ASC];
system.debug('Question -->' + qlist );
for(Quoting_Tool_Questions__c q:qlist){
wrapperlist.add(new ProposalManagementWrapper(q));
system.debug('WrapperList --->' + wrapperlist);
}
}catch(exception e){e.getMessage();}
return wrapperlist;
}
public void displayPanel(){
}
public class ProposalManagementWrapper{
public list <Quoting_Tool_Answeres__c> alist {get;set;}
public Quoting_Tool_Questions__c q {get;set;}
public boolean displayFlag{get;set;}
public string Key{get;set;}
public ProposalManagementWrapper (Quoting_Tool_Questions__c q){
this.q = q;
if(q.Dependent_Question__c == true){
this.displayFlag = true;
}else{
this.displayFlag = false;
}
if(q.Key__c != null){
Key = '-' + q.Key__c ;
}else{
Key = '';
}
this.alist = [select id,name,Answere__c,Key__c,Order__c,Quoting_Tool_Questions__c from Quoting_Tool_Answeres__c where Quoting_Tool_Questions__c =:q.Id ORDER BY Order__c ASC];
}
}
}
Page:
<apex:page sidebar="false" showHeader="false" controller="ProposalManagementController">
<style type="text/css">
.textfield{
border-bottom:solid;
border-width:1px;
border-bottom-color:#E0E0D1;
height:30px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$('*[id*=block-]:visible').each(function() {
$(this).hide();
});
});
function panelRender(val){
var id = "block-" + val;
alert(id);
$(id).show();
}
</script>
<apex:includeScript value="{!$Resource.Jquery}"/>
<apex:form>
<apex:pageBlock>
<table id="thetable" style="width:100%;">
<apex:repeat value="{!Questions}" var="wrapper">
<tr id="block{!wrapper.Key}">
<td class="textfield" >
<table style="width:60%;">
<tr>
<td style="width:20%;" align="right">
<apex:outputLabel for="timeframe"><b>{!wrapper.q.Question__c}</b></apex:outputLabel>
</td>
<td style="width:20%;" >
<apex:repeat value="{!wrapper.alist}" var="a">
<div>
<apex:outputText value="{!a.Answere__c}" >
<apex:inputCheckbox title="{!a.Name}" value="{!a.Key__c}" onclick="panelRender('{!a.Key__c}')"/>
</apex:outputText>
</div>
</apex:repeat>
</td>
</tr>
</table>
</td>
</tr>
</apex:repeat>
</table>
</apex:pageBlock>
</apex:form>
</apex:page>
On clicking the checkbox it is returing the correct Id and I am setting the id to show() but the panel is not displaying.
Can someone please look at the code
Controller
public class ProposalManagementController{
private list <Quoting_Tool_Questions__c> qlist;
public list <ProposalManagementWrapper> wrapperlist;
public ProposalManagementController(){}
public list <ProposalManagementWrapper> getQuestions(){
try{
wrapperlist = new list <ProposalManagementWrapper> ();
qlist = [select id,name,Question__c,Question_Order__c,Section_Name__c,Section_Order__c,Key__c,Dependent_Question__c from Quoting_Tool_Questions__c ORDER BY Question_Order__c ASC];
system.debug('Question -->' + qlist );
for(Quoting_Tool_Questions__c q:qlist){
wrapperlist.add(new ProposalManagementWrapper(q));
system.debug('WrapperList --->' + wrapperlist);
}
}catch(exception e){e.getMessage();}
return wrapperlist;
}
public void displayPanel(){
}
public class ProposalManagementWrapper{
public list <Quoting_Tool_Answeres__c> alist {get;set;}
public Quoting_Tool_Questions__c q {get;set;}
public boolean displayFlag{get;set;}
public string Key{get;set;}
public ProposalManagementWrapper (Quoting_Tool_Questions__c q){
this.q = q;
if(q.Dependent_Question__c == true){
this.displayFlag = true;
}else{
this.displayFlag = false;
}
if(q.Key__c != null){
Key = '-' + q.Key__c ;
}else{
Key = '';
}
this.alist = [select id,name,Answere__c,Key__c,Order__c,Quoting_Tool_Questions__c from Quoting_Tool_Answeres__c where Quoting_Tool_Questions__c =:q.Id ORDER BY Order__c ASC];
}
}
}
Page:
<apex:page sidebar="false" showHeader="false" controller="ProposalManagementController">
<style type="text/css">
.textfield{
border-bottom:solid;
border-width:1px;
border-bottom-color:#E0E0D1;
height:30px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$('*[id*=block-]:visible').each(function() {
$(this).hide();
});
});
function panelRender(val){
var id = "block-" + val;
alert(id);
$(id).show();
}
</script>
<apex:includeScript value="{!$Resource.Jquery}"/>
<apex:form>
<apex:pageBlock>
<table id="thetable" style="width:100%;">
<apex:repeat value="{!Questions}" var="wrapper">
<tr id="block{!wrapper.Key}">
<td class="textfield" >
<table style="width:60%;">
<tr>
<td style="width:20%;" align="right">
<apex:outputLabel for="timeframe"><b>{!wrapper.q.Question__c}</b></apex:outputLabel>
</td>
<td style="width:20%;" >
<apex:repeat value="{!wrapper.alist}" var="a">
<div>
<apex:outputText value="{!a.Answere__c}" >
<apex:inputCheckbox title="{!a.Name}" value="{!a.Key__c}" onclick="panelRender('{!a.Key__c}')"/>
</apex:outputText>
</div>
</apex:repeat>
</td>
</tr>
</table>
</td>
</tr>
</apex:repeat>
</table>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:inputField title="{!a.Name}" value="{!a.Key__c}">
<apex:actionSupport event="onchange" action="panelRender('{!a.Key__c}')"
rerender="<id of the section>"/>
</apex:inputField>
But I am getting this error 'Formula Expression is required on the action attributes.'
So action attribute cannot call a js script
http://www.cloudforce4u.com/2013/06/actionfunction-in-apex.html
Came across the below post that might provide some inputs on the same
https://developer.salesforce.com/forums/ForumsMain?id=906F000000096nfIAA