+ Start a Discussion

Content of inputText was changed from javascript, but no event onChange by the inputText


I make some calculations in javascript, becouse it's faster as waiting for response from server.

wenn I change content of inputText, it comes no even onChange and the setter of Variable will not called.


Here is the code:

var gesMen;
function calcPrice(elem){
    var path = elem.id.split(":");
    var root = elem.id.replace(path[path.length-1],"");
    gesMen = 10;
    document.getElementById(root+"anzVerp").value = gesMen;
    return null;



<apex:column headerValue="Anzahl Verpackungen">
    <apex:actionregion immediate="True">
        <apex:inputText value="{!anzVerp}"
            disabled="true" id="anzVerp">
            <apex:actionsupport event="onchange" />
            <apex:param name="Position" value="{!AP.lfdNr}" assignTo="{!applylfdNr}" />




This is standard browser behaviour.  The onchange event is fired when a user makes a change to an HTML input field, usually when focus is lost or the enter key is hit.  Events don't fire when you alter the contents via JavaScript - the assumption is that if you are making the change via JavaScript, you can also execute whatever JavaScript is associated with the onchange event.


In this case you'd want to change your actionsupport to an actionfunction and invoke that.



I have other question. can I invoke the setter-methods of fields witch will be changed in javascript?

also can I invoke methods of an apex-class in javascript? 


I doubt you'll be able to invoke the setters through javascript - these get invoked when the controller is updated with the viewstate changes once the page is submitted.


You can invoke action methods from javascript - take a look at the actionfunction component - that's exactly what its designed for.


can you Post the example to chnage field values on the form...