<apex:inputfield> and <apex:outputfield><ins

Example 1: Difference between <apex:inputfield> and <apex:outputfield>

<apex:page sidebar="false" standardController="account">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputfield value="{!account.name}"> </apex:outputfield>
<apex:inputfield value="{!account.phone}"></apex:inputfield>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Example 2: Placing input fields without using standard controller:

To place any input field you have to create a property for that object in apex class.
So that you can use that property name within input field to place the input component.

Visualfore page:

<apex:page Controller="ContactClass" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputfield value="{!con1.lastname}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Apex class

public with sharing class ContactClass {
public Contact con1{get;set;}
}

Example 3: Action function to populate the Address Fields:

In this scenario whenever we select an account from a contact
automatically the address fields are copied from account to contact.

Visualforce page

<apex:page standardController="Contact" extensions="ContactClass" sidebar="false">
<apex:form >
<apex:actionFunction name="populatefields" action="{!dopop}"/>
<apex:pageBlock >
<apex:pageBlockSection columns="1">
<apex:inputfield value="{!con1.AccountId}" onchange="populatefields()"/>
<apex:inputfield value="{!con1.Mailingcity}"/>
<apex:inputfield value="{!con1.Mailingcountry}"/>
<apex:inputfield value="{!con1.Mailingpostalcode}"/>
<apex:inputfield value="{!con1.Mailingstate}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Apex class

public with sharing class ContactClass {
public ContactClass(ApexPages.StandardController controller) {
con1 =(contact)controller.getRecord();
}
public PageReference dopop() {
Account objAcc =[select Id,name,Billingcity,Billingcountry,billingstate,billingpostalcode from Account where Id =:con1.AccountId ];
con1.Mailingcity=objAcc.billingcity;
con1.mailingcountry = objAcc.billingcountry;
con1.mailingpostalcode = objAcc.billingpostalcode;
con1.mailingstate = objAcc.billingstate;
return null;
}
public Contact con1{get;set;}
}