Showing posts with label Visualforce. Show all posts
Showing posts with label Visualforce. Show all posts

Friday, 26 September 2014

How to select only one checkbox value in visualforce page using javascript

Here is the code to select only one checkbox value in visualforce page by accessing DOM ID
Using the javascript and onchange event.
  1. <apex:page >
  2.     <apex:form >
  3.         <script>
  4.         function confirmDisbaled(ifchecked, id1 ,id2,id3) {
  5.             document.getElementById(id1).disabled = ifchecked;
  6.             document.getElementById(id2).disabled = ifchecked;
  7.             document.getElementById(id3).disabled = ifchecked;
  8.         }
  9.         </script>
  10.         <apex:pageBlock >
  11.             <apex:actionRegion >
  12.                 <apex:outputPanel id="panel1">
  13.                     <apex:pageBlockSection title="PST" id="PST">
  14.                        
  15.                         <apex:inputCheckbox label="Global" id="gbl" onchange="return confirmDisbaled(this.checked, '{!$Component.lcl}','{!$Component.cntry}');"/>
  16.                         <apex:inputCheckbox label="Local" id="lcl" onchange="return confirmDisbaled(this.checked, '{!$Component.gbl}','{!$Component.cntry}');"/>
  17.                         <apex:inputCheckbox label="Country" id="cntry" onchange="return confirmDisbaled(this.checked, '{!$Component.lcl}','{!$Component.gbl}');"/>
  18.                        
  19.                     </apex:pageBlockSection>
  20.                 </apex:outputPanel>
  21.             </apex:actionRegion>
  22.         </apex:pageBlock>
  23.     </apex:form>
  24. </apex:page>

Thursday, 11 September 2014

How to make Command Link as Command Button in Visualforce page using CSS


We can show command link as standard salesforce command button in visualforce page by applying CSS Style.

Here is the code,

<apex:commandLink  styleClass="btn" style="text-decoration:none;padding:4px;"  value=" Click me"/>


Thanks for reading this post...!

Thursday, 5 June 2014

How to Show IP Address in Visualforce Page Salesforce


      In some of point of requirement you may need to show the IP address in visualforce page. The following is the way to show IP address in salesforce.

Apex Class
  1. public class IPAddress
  2. {
  3. public string myIPAddress{get;set;}
  4.    public IPAddress()
  5.    {
  6.       myIPAddress = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');
  7.    }
  8. }
Visualforce page
  1. <apex:page controller="IPAddress" >
  2. Your Login IP Address : {!myIPAddress}
  3. </apex:page>

Here is the IP Address


Tuesday, 27 May 2014

Getting related contact records as a inputCheckBox values for the selected Account in visualforce page

Here is the code for Getting related contact records as a inputCheckBox values for the selected Account in visualforce page.

Apex Class:

01public class contactCheckbox
02{
03public contact selectedAccount{get;set;}
04
05 public contactCheckbox(ApexPages.StandardController stdCtrl) {
06selectedAccount=(Contact)stdCtrl.getRecord();
07    }
08
09     public List<SelectOption> getItems()
10      {
11    
12      List<Contact> cntList=[select Name from Contact
       where AccountId=:selectedAccount.AccountID];

13      List<SelectOption> options = new List<SelectOption>();
14         
15        for (Contact c:cntList)
16        {
17            options.add(new SelectOption(c.Name,c.Name));
18        }
19        return options;
20      }
21       
22
23}
Visualforce Page


01<apex:page standardController="Contact" extensions="contactCheckbox"
showheader="false">
02
03<apex:form >
04<center>
05<br/>
06<br/>
07        <apex:outputLabel value="Account Name"> 
08                 
09         <apex:inputField value="{!Contact.AccountId}" required="false" id="lid">
<br/><br/><br/>
10         <apex:actionsupport event="onchange" rerender="check"/>
11         </apex:inputField>
12                 
13         </apex:outputLabel>
14         <apex:outputPanel id="check">
15         <apex:outputLabel value="Contacts:" rendered="{!contact.AccountId!=null}">
16         <apex:selectCheckboxes value="{!selectedAccount}">
17            <apex:selectOptions value="{!items}"/>
18        </apex:selectCheckboxes><br/>
19        </apex:outputLabel>
20        </apex:outputPanel>
21</center>
22</apex:form>
23
24</apex:page>

Output

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...