You need to sign in to do that
Don't have an account?
paddu
urgent help: Using actionSupport
Hi,
How to display a text filed dynomically when selecting a Picklist option on a VF page. For example picklist values are val1, val2 & val3, i want to display a text field only when selecting val3. I think it could be done by using actionSupport & reRender, but I never worked on actionSupport, can any one help me how to achieve this throught actionSupport or any other approach ?.
Any help must be highly appreacted.
Thanks in advance!
if you are not that familiar with apex please use the below :
replace the checkbox field with your picklist, if needed assign the values using a formula
--yvk
All Answers
if you are using input field
<page id="pg" standardcontroller="object" extensions="controller">
<apex:form id+"frm">
<apex:pageBlock id="pgb">
<apex:outputPanel id="outpnl">
<apex:pageBlockSection id = "pgbs" columns="1">
<apex:pageBlockSectionItem id="pbsipck">
<apex:outputLabel value="picklist" />
<apex:actionRegion >
<apex:inputField value="{!object.picklistId}" id="pcknm">
<apex:actionSupport event="onchange" action="{!pckChange}" rerender="pbstxtfld"/>
</apex:inputField>
</apex:actionRegion>
</apex:pageBlockSectionItem>
<apex:inputField id="txtid" value="{!object.txtid}"/>
</apex:pageBlockSection>
</apex:outputPanel>
here in the action funciton you can have a void function and assign the value to the text field or instead of a action you can assign the value directly using javascript using actionFunction
<page id="pg" standardcontroller="object" extensions="controller">
<apex:form id+"frm">
<apex:actionFunction name="refreshtxt" rerender="txtid,pgbs"/>
<apex:pageBlock id="pgb">
<apex:outputPanel id="outpnl">
<apex:pageBlockSection id = "pgbs" columns="1">
<apex:inputField value="{!object.picklistId}" id="pcknm" onchange="javascript:updatetxt();"/>
<apex:inputField id="txtid" value="{!object.txtid}"/>
</apex:pageBlockSection>
</apex:outputPanel>
<script>
function updatetxt()
{
var Pck = document.getElementById("pg:frm:pgb:pgbs:pcknm");
if(Pck.options[Pck.selectedIndex].value == 'Some thing')
document.getElementById("pg:frm:pgb:pgbs:txtid").value = 'some thing';
refreshtxt();
}
</script>
Hi,
Thanks you very much for your reply. It would be great if you can provide the sample controller class for the give VF page, i.e how to write a action method {!pckChange} in controller.
Regards,
paddu
if you are not that familiar with apex please use the below :
replace the checkbox field with your picklist, if needed assign the values using a formula
--yvk
Thank you very much. Really appreciate your help...
Regards,
Paddu