function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
<apex:page controller="HideShowController"> <apex:form > <apex:pageBlock > <apex:pageBlockSection > 1.question? <apex:pageBlockSectionItem > <apex:commandButton action="{!answer}" value="YES" rendered="{!answer}"></apex:commandButton> <apex:commandButton action="{!skipquest}" value="NEXT" rendered="{!nextquest}"></apex:commandButton> </apex:pageBlockSectionItem> <apex:outputLabel rendered="{!solution}">answer1</apex:outputLabel> </apex:pageBlockSection> <apex:pageBlockSection > <apex:outputLabel rendered="{!quest2}">2.question</apex:outputLabel> <apex:pageBlockSectionItem > <apex:commandButton action="{!answer1}" value="YES" rendered="{!answer1}" ></apex:commandButton> <apex:commandButton action="{!skipquest1}" value="NEXT" rendered="{!nextquest1}" ></apex:commandButton> </apex:pageBlockSectionItem> <apex:outputLabel rendered="{!solution2}">answer2</apex:outputLabel> </apex:pageBlockSection> </apex:pageblock> </apex:form> </apex:page>
public with sharing class HideShowController { public boolean solution2 { get; set; } public boolean quest2 { get; set; } public boolean solution1 { get; set; } public boolean solution { get; set; } public boolean nextquest1 { get; set; } public boolean answer1 { get; set; } public Boolean nextquest { get; set; } public Boolean answer { get; set; } public HideShowController(){ answer=true; nextquest=true; solution=false; quest2=false; solution2=false; } public PageReference skipquest() { answer=false; nextquest1=true; quest2=true; nextquest=false; answer1=true; return null; } public PageReference answer() { solution=true; answer=false; return null; } public PageReference skipquest1() { return null; } public PageReference answer1() { solution2=true; answer1=false; return null; } }
<apex:page controller="ControllerClass"> <apex:form > Enter First Value <apex:inputText value="{!a}"/> <br/> Enter Second Value <apex:inputText value="{!b}"/><br/> <apex:commandButton value="Add" action="{!value1}" rendered="{!v1}"/> <apex:commandButton value="Subtract" action="{!value2}" rendered="{!v2}"/> <apex:commandButton value="Multiply" action="{!value3}" rendered="{!v3}"/><br/> <apex:outputText value="{!res}"/> </apex:form> </apex:page>
public class ControllerClass { public Integer res { get; set; } public Integer b { get; set; } public Integer a { get; set; } public Boolean v1 { get; set; } public Boolean v2 { get; set; } public Boolean v3 { get; set; } public ControllerClass (){ v1=true; v2=true; v3=true; } public PageReference value1() { v1=false; v2=true; v3=true; res=a+b; return null; } public PageReference value2() { v2=false; v1=true; v3=true; res=a-b; return null; } public PageReference value3() { v3=false; v1=true; v2=true; res=a*b; return null; } }
Please check the below sample code (e.g: Online exam questions)
VisualForce Page:
Controller:
Hope this helps you!
Best Regards,
Jyothsna
I have worked on this requirement with some sample code on Visualforce page.
You can also check the below links:
https://developer.salesforce.com/forums/?id=906F0000000AwcHIAS
https://developer.salesforce.com/forums/?id=906F0000000A6XlIAK
https://developer.salesforce.com/forums/?id=906F0000000A6XlIAK
Regards,
Deepthi