0

I have an input box and I would like it to call a function whenever the value is changed, is that possible? I have tried:

 <div class="slds-form-element__control" id="annn">
      <apex:form ><apex:actionfunction name="onchangemethod" action="{!valueupdate}" rerender="annn"></apex:actionfunction>
      <input type="text" id="InptAnnVol" class="slds-input" value="{!InptAnnVol}" onchange="onchangemethod()"/></apex:form>
 </div>
Controller:
public void valueupdate(){
        decimal test;
        test = decimal.valueof(InptAnnVol);
        InptAnnvol = test.format();

    }
1

You need to call a action function when ever something changes in the text field. You need to send that value to controller method using apex:param

VF:

  <apex:actionfunction name="onChangeActMethod" action={!valueupdate} rerender="refreshing">
<apex:param name="valFromVf" value=""/>
</apex:actionFunction>

<input type="text" id="input-id-02" class="slds-input" value="{!InptAnnVol}"  onchange="onChangeActMethod(this.value);"/>

Controller:

public void valueupdate(){
    string x=Apexpages.currentPage().getParameters().get('valFromVf');
    decimal test;
    test = decimal.valueof(x);
    InptAnnvol = test.format();

}
  • that works but I want to send the value of the input field but the method is using the value the input field originated with, my post is updated. – AverageJoeVBA Jun 27 '17 at 13:47
  • see update code – night crawler Jun 27 '17 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.