Hmm.. LotsAfter a lot of trials trials and.. at Last I, found the solution....
<apex:page controller="SelectList3">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Contact List">
<apex:selectList value="{!slv}" size="1" label="Contaclist">
<apex:actionSupport event="onchange" reRender="table" />
<apex:selectOptions value="{!value}">
</apex:selectOptions>
</apex:selectList>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<apex:pageBlock title=" Value of contacts">
<apex:pageBlockSection >
<apex:outputPanel id="out">
<apex:pageblockTable value="{!tabledata}" var="c" cellpadding="2px" id="table">
<apex:column value="{!c.name}" headerValue="Account Name"/>
</apex:pageblockTable>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock> </apex:page>
------------------------ Controller------------------------------------------
public with sharing class SelectList3
{
{
public list<Account> getTabledata()
{
list<Account> con=[select name from Account where id=:slv];
return con;
}
public list<selectoption> getValue()
{
list<SelectOption> ls= new list<SelectOption>();
for(Account acc:[select id, name from Account])
{
ls.add(new SelectOption(acc.id,acc.name));
}
return ls;
}
public string slv{get;set;}
}