function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alex85Alex85 

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

Hi.

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:

<script>
var gesMen;
</script>
    <script>
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;
}

</script>

 

<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}" />
        </apex:inputText>
    </apex:actionregion>
</apex:column>

 

Thanks

bob_buzzardbob_buzzard

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.

Alex85Alex85

Hi.

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? 

bob_buzzardbob_buzzard

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.

venkatasubhashkvenkatasubhashk

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