You need to sign in to do that
Don't have an account?
Jina Chetia
How to Hide/show a pageBlock depending upon the button selection?
Hi,
I am trying to build a questionare page where on click of Yes/No will determine the second question. I will have all the question on the same page in different page blocks but I dont want them to appear together. Suppose I select 'Yes' for the first question then display the second question which is in the second pageblock, if no then show a different question.
In the code below - I having two pageblocks and on select of 'Yes' button I want to display the content in the second pageblock and if 'No' then don't show the next question. I was trying to dynamically set the value of 'rendered' in the controller depending on the button selected but it is not working. Everytime I call the Controller onclick of button, it sets the value for ' rendered ' but since the page reloads, I lose my set value and it is always the default false and the second section never appears.
Please find the code of my Controller and Page below-
<apex:page controller="Wizard_3a_Controller">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection title='Rate Information'>
Are there proposed non-standard electronic rates?<br/>
<apex:commandButton onclick='{!showSection1}' value='Yes' styleClass='btn'></apex:commandButton>
<apex:commandButton onclick='{!showSection2}' value='No' styleClass='btn'></apex:commandButton>
</apex:pageBlockSection>
<apex:outputPanel id='details'>
<apex:pageBlockSection id ='newData' title='Discount Rates' rendered='{!hideshow}'>
Enter Proposal range -
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
public class Wizard_3a_Controller
{
Boolean testval = false;
public String getShowSection1()
{
testval= true;
return null;
}
public String getShowSection2()
{
testval= false;
return null;
}
public Boolean getHideshow()
{
return testval;
}
}
The value of hideshow is not getting changed, it is always false.
Can anyone please help me soving this issue?
Thanks
Jina
I am trying to build a questionare page where on click of Yes/No will determine the second question. I will have all the question on the same page in different page blocks but I dont want them to appear together. Suppose I select 'Yes' for the first question then display the second question which is in the second pageblock, if no then show a different question.
In the code below - I having two pageblocks and on select of 'Yes' button I want to display the content in the second pageblock and if 'No' then don't show the next question. I was trying to dynamically set the value of 'rendered' in the controller depending on the button selected but it is not working. Everytime I call the Controller onclick of button, it sets the value for ' rendered ' but since the page reloads, I lose my set value and it is always the default false and the second section never appears.
Please find the code of my Controller and Page below-
<apex:page controller="Wizard_3a_Controller">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection title='Rate Information'>
Are there proposed non-standard electronic rates?<br/>
<apex:commandButton onclick='{!showSection1}' value='Yes' styleClass='btn'></apex:commandButton>
<apex:commandButton onclick='{!showSection2}' value='No' styleClass='btn'></apex:commandButton>
</apex:pageBlockSection>
<apex:outputPanel id='details'>
<apex:pageBlockSection id ='newData' title='Discount Rates' rendered='{!hideshow}'>
Enter Proposal range -
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
public class Wizard_3a_Controller
{
Boolean testval = false;
public String getShowSection1()
{
testval= true;
return null;
}
public String getShowSection2()
{
testval= false;
return null;
}
public Boolean getHideshow()
{
return testval;
}
}
The value of hideshow is not getting changed, it is always false.
Can anyone please help me soving this issue?
Thanks
Jina
also, if you could post your src code inside a SRC block, it is easier to test your code. the smilies don't compile.
hi,