You need to sign in to do that
Don't have an account?
Show/Hide outpanel onClick event?? Please Help
Hi:
I have 2 links. I have 2 booleans to show or hide a form. Each link relates to a different part of the page.
VF Page:
<apex:form id="menu"> <table border="0" cellspacing="0" cellpadding="0"> <tr><th> <apex:commandLink id="menustudent" value="Student" action="{!showform}" rerender="student"/> </th><th> <apex:commandLink id="menuteacher" value="Teacher" action="{!showform2}" rerender="teacher"/> </th></tr> </table> </apex:form> <apex:outputPanel id="stud" rendered="{!displaystudent}"> <apex:outputPanel layout="block" > <apex:form > blahblahblah </apex:form> <apex:outputPanel id="stud" rendered="{!displayteacher}"> <apex:outputPanel layout="block" > <apex:form > blahblahblah t </apex:form>
Controller:
public boolean displaystudent {get; set;} public boolean displayteacher {get; set;} public void closeform() { displaystudent = false; displayteacher= false; } public void showform() { displaystudent = true; } public void showform2() { displayteacher= true; }
It works when you click on it once but it does not hide the form when you click on another link. It brings both up and I do not know how to utilize my closeform command???
please help..
Thanks
I think the problem may be your reRender attributes. Try putting a single outputPanel between both forms then reRendering this one outputPanel (in the below example reRender 'forms'):
<apex:outputPanel id="forms">
<apex:outputPanel rendered="{!displaystudent}">
...Student form here </apex:outputPanel>
<apex:outputPanel rendered="{!displayteacher}"> ... Teacher form here </apex:outputPanel>
</apex:outputPanel>
All Answers
Not sure I fully understand what you're trying to do, but if I'm following, you only want one of these forms to display at a time? You could solve the problem by setting the appropriate boolean to false when the links are clicked. This would just require an extra statement in each showform() method
public boolean displaystudent {get; set;} public boolean displayteacher {get; set;} //display student, make sure teacher doesn't display public void showform() { displayteacher = false; displaystudent = true; } //display teacher, make sure student doesn't display public void showform2() { displaystudent = false; displayteacher= true; }
Thank you...
I did try that out before the issue is when an user clicks on the link of student the student form appears. which is good, but when the user clicks on teacher then teacher form appears below the student form. Hence both forms are there...
So I did change it to your way, and I still get both forms up when I click on the link...
Like it will not hide the other form when you click on the link.., for example click on student ==> student for appears.. now click on teacher and student form does not hide away it stays there and teacher form appears...
I just want the appropiate form to appear for the appropiate links clicked...
Thanks
I think the problem may be your reRender attributes. Try putting a single outputPanel between both forms then reRendering this one outputPanel (in the below example reRender 'forms'):
<apex:outputPanel id="forms">
<apex:outputPanel rendered="{!displaystudent}">
...Student form here </apex:outputPanel>
<apex:outputPanel rendered="{!displayteacher}"> ... Teacher form here </apex:outputPanel>
</apex:outputPanel>