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
balaji_SFDCbalaji_SFDC 

How to show Account name in popup

Hi Experts,

In my org I display the account records using pageblocktable tag with columns Account name,Location and id. When i click on Account name in list of records i want to display in popup is "you selected record is Account name". For example when i click on joint account record it will display in popup "you selected record is joint" .

Please anyone can help me how to achieve this

Thanks,
Balaji
Best Answer chosen by balaji_SFDC
praveen murugesanpraveen murugesan
Hi Balaji,

Here is the code.. Modify based on your requirement.

<apex:page standardController="Account" Extensions="PopUpMessageController" sidebar="false">
<style>
 .custPopup
{
    background: #fff ;
    border-width: 2px;
    border-style:inset;
    z-index: 9999;
    left: 720px;
    padding:10px;
    position: absolute;
    /* These are the 3 css properties you will need to change so the popup 
    displays in the center of the screen. First set the width. Then set 
    margin-left to negative half of what the width is. You can add 
    the height property for a fixed size pop up if you want.*/
    width: 650px;  
    margin-left: -250px;
    top:100px;
}
.popupBackground
{
    background-color:black;
    opacity: 0.20;
    filter: alpha(opacity = 20);
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 9998;
}
</style>

 <apex:form >
 <apex:pageBlock >
 <apex:pageBlockTable value="{!accList}" var="acc" >  
                                
    <apex:column headerValue="{!$ObjectType.Account.Fields.Name.Label}">
   
    <apex:commandLink value="{!acc.Name}" action="{!userSelected}" rerender="tstpopup">  
    <apex:param name="AccID" value="{!acc.Id}" />
    </apex:commandLink>
    </apex:column>
    <apex:column headerValue="{!$ObjectType.Account.Fields.Phone.Label}" >                                   
    <apex:outputText value="{!acc.Phone}" />                                        
    </apex:column>
  </apex:pageBlockTable>
   
  <apex:outputPanel id="tstpopup">
  <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayAccListPopup}"/>
      <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayAccListPopup}">
          Selected account is {!selectedAcc.name}; <br/><br/>
      <apex:commandButton value="Hide Pop up" action="{!closePopup}" rerender="tstpopup"/>
  </apex:outputPanel>
  </apex:outputPanel>

  </apex:pageBlock> 
 </apex:form>                              
 </apex:page>
public with sharing class PopUpMessageController {
    
    public list<Account> accList{get;set;}
    public Account selectedAcc{get;set;}
    public boolean displayAccListPopup {get; set;}  
    
    public PopUpMessageController(ApexPages.StandardController controller) {
           accList = [select id,name,phone from Account order By name asc];        
    }
    
     public void ClosePopup() 
    {   
        displayAccListPopup = false;    //Setting show popup false
    }   
    
    public pageReference userSelected()
    {       
        displayAccListPopup = true;  //Setting show popup true
          
        string accId = ApexPages.currentPage().getParameters().get('AccID');
         selectedAcc= [select id,name,phone from Account where id =: accId];        
        return null;
    }      
       

}

Mark this as best answer if its helps.

Thanks

All Answers

praveen murugesanpraveen murugesan
Hi Balaji,

Here is the code.. Modify based on your requirement.

<apex:page standardController="Account" Extensions="PopUpMessageController" sidebar="false">
<style>
 .custPopup
{
    background: #fff ;
    border-width: 2px;
    border-style:inset;
    z-index: 9999;
    left: 720px;
    padding:10px;
    position: absolute;
    /* These are the 3 css properties you will need to change so the popup 
    displays in the center of the screen. First set the width. Then set 
    margin-left to negative half of what the width is. You can add 
    the height property for a fixed size pop up if you want.*/
    width: 650px;  
    margin-left: -250px;
    top:100px;
}
.popupBackground
{
    background-color:black;
    opacity: 0.20;
    filter: alpha(opacity = 20);
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 9998;
}
</style>

 <apex:form >
 <apex:pageBlock >
 <apex:pageBlockTable value="{!accList}" var="acc" >  
                                
    <apex:column headerValue="{!$ObjectType.Account.Fields.Name.Label}">
   
    <apex:commandLink value="{!acc.Name}" action="{!userSelected}" rerender="tstpopup">  
    <apex:param name="AccID" value="{!acc.Id}" />
    </apex:commandLink>
    </apex:column>
    <apex:column headerValue="{!$ObjectType.Account.Fields.Phone.Label}" >                                   
    <apex:outputText value="{!acc.Phone}" />                                        
    </apex:column>
  </apex:pageBlockTable>
   
  <apex:outputPanel id="tstpopup">
  <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayAccListPopup}"/>
      <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayAccListPopup}">
          Selected account is {!selectedAcc.name}; <br/><br/>
      <apex:commandButton value="Hide Pop up" action="{!closePopup}" rerender="tstpopup"/>
  </apex:outputPanel>
  </apex:outputPanel>

  </apex:pageBlock> 
 </apex:form>                              
 </apex:page>
public with sharing class PopUpMessageController {
    
    public list<Account> accList{get;set;}
    public Account selectedAcc{get;set;}
    public boolean displayAccListPopup {get; set;}  
    
    public PopUpMessageController(ApexPages.StandardController controller) {
           accList = [select id,name,phone from Account order By name asc];        
    }
    
     public void ClosePopup() 
    {   
        displayAccListPopup = false;    //Setting show popup false
    }   
    
    public pageReference userSelected()
    {       
        displayAccListPopup = true;  //Setting show popup true
          
        string accId = ApexPages.currentPage().getParameters().get('AccID');
         selectedAcc= [select id,name,phone from Account where id =: accId];        
        return null;
    }      
       

}

Mark this as best answer if its helps.

Thanks

This was selected as the best answer
balaji_SFDCbalaji_SFDC
Hi praveen murugesan,

Thanks for your Reply. It is working expected
praveen murugesanpraveen murugesan
Hi,

YOu are welcome.