You need to sign in to do that
Don't have an account?
NareshKrishna
Need help with apex:selectList onChange()
Hi All,
Could any one please help me with the following:
I have a page with a select list having 3 options and inputText.
<apex:outputLabel >Type:</apex:outputLabel>
<apex:selectList value="{!type}" size="1">
<apex:selectOptions value="{!selectTypeOptions}"/>
</apex:selectList>
<apex:outputLabel >Name:</apex:outputLabel>
<apex:inputText value="{!name}">
Upon changing the option in the selectList, have to change value in the inputText.
Please help with this.
Thanks.
Hi,
Give an ID to your inputtext field and Write a JavaScript function in which you will assign a value to your inuttext filed as the value of selectlist and call this function onchange event of selectlist and re render the output panel under which you will keep your inputtext box.
You can try below javscript code
function inputtex()
{
selectList = document.getElementById('{!$Component.thepage:theform:sletlistid}');
var selectOptions = selectList.getElementsByTagName('option');
for(Integer i=0;i<selectOptions.Length();i++)
{
var opt = selectOptions[i];
if(opt.selected == true)
{
document.getElementById('{!$Component.thepage:theform:inputtextboxid}').value=selectOptions[i].value;
}
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.