Thursday, 10 September 2015

Beautiful HTML buttons with simple css

<html>
<head>
<style>
 input:hover, button:hover {
    background:white;color:black;
}
.btn{
box-shadow: 10px 10px 5px#888888; width:200px; height:50px; background:black;     color:white; border-radius:5px;
}
</style>
</head>
<body>
<input type="button" value="button" class="btn"></input>
<button class="btn">Home</button>
<button class="btn">Contact</button>
<button class="btn">Help</button>
</body>
</html>

Put cursor at end of text input's value



<input type="text"  style="text-align:right;" onfocus="this.value = this.value;" value="120" autofocus="autofocus">

Example: 


Source: http://stackoverflow.com/questions/17780756/put-cursor-at-end-of-text-inputs-value

Sunday, 6 September 2015

Working with fielsets in salesforce

Working with Field Sets Using Visualforce

<apex:page standardController="Contact">
    <apex:repeat value="{!$ObjectType.Contact.FieldSets.properNames}" var="f"> 
        <apex:outputText value="{!Contact[f]}" /><br/>
    </apex:repeat>
</apex:page>

------------------------------------------------------------------------------------

Working with Field Sets Using Apex


public class MerchandiseDetails {

    public Merchandise__c merch { get; set; }
    
    public MerchandiseDetails() {
        this.merch = getMerchandise();
    }

    public List<Schema.FieldSetMember> getFields() {
        return SObjectType.Merchandise__c.FieldSets.Dimensions.getFields();
    }

    private Merchandise__c getMerchandise() {
        String query = 'SELECT ';
        for(Schema.FieldSetMember f : this.getFields()) {
            query += f.getFieldPath() + ', ';
        }
        query += 'Id, Name FROM Merchandise__c LIMIT 1';
        return Database.query(query);
    }
}