function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Reshmi SmijuReshmi Smiju 

Diplay a Text field when clicking a CommandLink.

Hi,

I would like to display a Text Field when clicking Command Link ( Title:Add Filter Logic ).After the clicking of commandlink, the link title should be renamed to Clear Filter Logic. It would be great, if anyone let me know, how to do this.
User-added image
Amit Chaudhary 8Amit Chaudhary 8
Please check below post. I hope that will help you
http://www.infallibletechie.com/2013/04/hide-and-show-example-using-apex-in.html

Please let us know if this will help you
Just replace command button with link


 
Reshmi SmijuReshmi Smiju
Hi Amit,

Thank you for your response. I am not quite sure, how the visible the Text field and rename the Link name on clicking the Link. It would be great, if you could provide some related code for the same. Thanks
Amit Chaudhary 8Amit Chaudhary 8
Please try below code.
public class HideAndShow
{
    public Boolean abool {get;set;}
    public Boolean bbool {get;set;}
   
    public Boolean sabool {get;set;}
    public Boolean sbbool {get;set;}
    public Boolean habool {get;set;}
    public Boolean hbbool {get;set;}
    public Boolean sabbool {get;set;}
    public Boolean habbool {get;set;}
   
    public HideAndShow()
    {
        sabool = true;
        sbbool = true;
        sabbool = true;
        abool = false;
        bbool = false;
    }
   
    public void showA()
    {
        abool = true;
        check();
    }
   
    public void showB()
    {
        bbool = true;
        check();
    }  
    
    public void hideA()
    {
        abool = false;
        check();
    }
   
    public void hideB()
    {
        bbool = false;
        check();
    }  
   
    public void showAB()
    {
        abool = true;
        bbool = true;
        check();
    }  
   
    public void hideAB()
    {
        abool = false;
        bbool = false;
        check();
    }   
   
    public void check()
    {
        if(abool == true && bbool == false)
        {
            sabool = false;
            sbbool = true;
            habool = true;
            hbbool = false;
            sabbool = true;
            habbool = false;
        }
        else if(abool == false && bbool == true)
        {
            sabool = true;
            sbbool = false;
            habool = false;
            hbbool = true;
            sabbool = true;
            habbool = false;
        }
        else if(abool == true && bbool == true)
        {
            sabool = false;
            sbbool = false;
            habool = true;
            hbbool = true;
            habbool = true;
            sabbool = false;

        }
        else
        {
            sabool = true;
            sbbool = true;
            habool = false;
            hbbool = false;
            sabbool = true;
            habbool = false;
        }
    }   
}
<apex:page controller="HideAndShow" sidebar="false" showHeader="false" >
<apex:form >

    <apex:pageBlock title="Block A" rendered="{!abool}">
        This is Block A.<br/><br/>       
    </apex:pageBlock>
   
    <apex:pageBlock title="Block B" rendered="{!bbool}">
        This is Block B.<br/><br/>
    </apex:pageBlock>   
   
    <apex:pageBlock >
        
    
        <apex:commandLink value="Show A" action="{!showA}" rendered="{!sabool}" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <apex:commandLink value="Hide A" action="{!hideA}" rendered="{!habool}" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <apex:commandLink value="Show B" action="{!showB}" rendered="{!sbbool}" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <apex:commandLink value="Hide B" action="{!hideB}" rendered="{!hbbool}" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    </apex:pageBlock>
</apex:form>   
</apex:page>
Please let us know if this will help you


 
Gyanender SinghGyanender Singh
Hi Reshmi Smiju,

you can achieve this functionality by using javascript in the vf page , please try the below code and let me know this is the solution of your problem.
 
<script>
        function show(){
            document.getElementById("div2").style.display = 'Inline';
            document.getElementById("div1").style.display = 'None';
        }
        
        function hide(){
            document.getElementById("div1").style.display = 'Inline';
            document.getElementById("div2").style.display = 'None';
        }
    </script>
    <div id="div1">
        <a href="#" onclick="show();">Clear Filter Logic</a><br/>
        <b>Filter Logic</b>
    </div>
    
    <div id="div2" style="display: none;">
        <a href="#" onclick="hide();">Add Filter Logic</a><br/>
        <b>Add Filter Logic</b>
    </div>

Thanks
Gyani