Parented Selects onChange Event

I have a select dropdown (manually populated)
dependent of another select dropdown (normal, lookup table values)it did work ok on first page load, but it is suposed to change when parent field change, but didn’t work…

So
In Custom Edit tag (child field) I have

<select class="form-control">
<?php
	$listoptions = $something->list();
	for ($p = 0; $p < $listOptions ->getOptionNumbers(); $p ++) {
		$option = $listOptions ->getOption($p);
		$value = $listOptions ->getId();
		$option = $listOptions ->getName();
		echo "<option value=".$value .">".$option ."</option>";
	}
?>
</select>

But, I assume that I missing some onchange event in parent field, prbably in Client SIde Events, or in Startup script, or both… that made $listoptions of child field be recalculated…
Any clue?

If you don’t use the built-in Dynamic Selection Lists and use Custom Edit Tag, then you need to write your own code to update your custom form control. You better use Lookup_Selecting server event, see: https://discourse.hkvstore.com/t/populate-a-select-tag-with-dynamic-values-or-from-table/4362/1

Ok… I’ll try with Lookup_selecting, but still I’ll be missing some onchange event in parent field, that made options values be recalculated… or not?
I mean… the select list populate did worked… I’m fail on update listoptins when parent select field change.
Select
Countries (by lookup table)
USA (Default)
Canada
MéxicoState (by lookup_selecting event)
Utah (Default)
California
IllinoisChange by
Cuernava
Morelos
Vercaruz
If a choose México.

If it is a child field of Dynamic Selection Lists, you need to add the filter field value (the 6th value in each option) also.

The closest approach for this is by using Dynamic Selection List feature as arbei suggested above. Please read this topic from PHPMaker Help menu for more info and example.

It doesn’t work… at least not like I want.
What I need is to know where should I add the event to update the list on change parent field.
And, if is possible, what should say that onChange event…

You may try:

$document.on("addoption", function (e, args) {
// console.log(e, args); // Check arguments and use them to set the option as valid/invalid
// args.valid = false; // Returns false if invalid
});

Ok, but where?
Client scripts

  • Table Specific
    – Client Script
    or
    Client scripts
  • Table Specific
    – Startup Script

On
Partent field
Edit tag

  • Client side events
    or

Chield field
Edit tag

  • Client side events

You may try Client Script of the page.