Selected Drop Down value with onChange

Hello, I have a Drop Down (z_prefix) that contains a list of values that the user selects from. The section is then used as a prefix for a manually entered description in a text box (z_description). using this returns the previously selected value in the drop down, not the currently selected one: var pre = getFieldByName("z_prefix").getElementsByTagName("input")[0].value; this has the same issue: var select = getElementById("z_prefix"); var pre = select.options[select.selectedIndex].text; Whats the syntax for the currently entered one?
  • Hello, It looks like in 11.0 SP12, the onChange event is called just before the change to the dropdown is actually set. In order to access the value, I'd recommend setting a timeout with a very small duration and looking up the value in there like the example below.
    setTimeout(function() {
    var value = getFieldByName("z_prefix").getElementsByTagName("input")[0].value;
    }, 10); // <-- 10ms worked in my test environment, but you may find you need to increase the duration of this timeout
    I would have filed this behavior to be fixed, but it seems this has already been updated in the recently released 11.0 SP15 which is available to subscribers. In SP15, you can simply call this.value without the timeout in order to retrieve the new value in an onChange event. Chris
    Christopher Gillis Aras Labs Software Engineer
  • Great, thanks Chris, that worked. Yes I'm a subscriber, so will be updating!