0

Below is the sample code(I wrote it randomly). oncomplete of the actionfunction, javascript is being called, but the picklist value is being "undefined". I even tried $component.id, but the picklist value is still being "undefined". Any help is much appreciated. Thanks.

<apex:form id="the form">
<apex:pageblocksectionItem>
 <apex:outputlabel> hi </apex:outputlabel>
  <apex:actionregion>
    <apex:inputfield value="{!picklist}" onchange="change();"/>
  </apex:actionregion>
</apex:pageblocksectionItem>

<apex:actionfunction name="change" action={!apexmethod} rerender="theForm" oncomplete"callscript()" />

</apex:form>

<script>
 function script()
{
if(picklist == 'yes')
{
  alert ('random info');
}
}
</script>
1
  • 1
    hmm where to begin.. there are so many issues in the code..syntax wise & usage as well.. what exactly is your requirement ? Commented Aug 6, 2014 at 6:14

1 Answer 1

1

To start, you need to reference the field via a selector or id

Lots of stuff to say, but this should solve your immediate issue

<apex:form id="the form">
<apex:pageblocksectionItem>
 <apex:outputlabel> hi </apex:outputlabel>
  <apex:actionregion>
    <apex:input field id="thefield" value="{!picklist}" onchange="change();"/>
  </apex:actionregion>
</apex:pageblocksectionItem>

<apex:actionfunction name="change" action={!apexmethod} rerender="theForm" oncomplete"callscript()" />

</apex:form>

<script>
 function script()
{
if(document.getElementById('{!$Component.thefield}').value == 'yes')
{
  alert ('random info');
}
}
</script>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .