Help! Change event based on the value of first selection

I have this change event and i want to display the value of children based on the value of enrollmentId both are select, the change event is actually works on the console i can see the id of the enrollmentId but on the children option, all children is being passed.

  'change select[name=enrollmentId]': function(event, template) {
    var enrollmentId = $(event.target).val();
    console.log(enrollmentId);
    template.$('select[name=childrenId]').val(enrollmentId);
  },

the enrollmentId is actually the father so if the user select the father, only his children will appear on the dropdown.

Any help would deeply appreciated.

Thanks,

I don’t understand what you are asking. Could you post your template and helpers also, then it might be easier to see what you mean.

Hi @jorgeer,

My use case is on my form I have enrollmentId selection and children selection, basically i want to filter the children based on the selection on enrollmentId. This two fields are relation from other collection,

I use orionjs. The relationship in orion has two kinds hasOne and hasMany, enrollmentId hasOne and children hasMany. The enrollmentId is the name of the one who enrolled on the insurance and he has a children as a dependent, my user want is if they select an enrollee the only thing will appear on the children dropdown is this enrollees children not from other enrollee.

Does it make sense?

Here’s my template:
{{#autoForm collection=collection id=“orionBootstrapCollectionsCreateForm” type=“insert” buttonContent=false }}
{{> afQuickField name=“enrollmentId” }}
{{> afQuickField name=“childrenId”}}
{{> afQuickField name=“status” }}
{{> afQuickField name=“causeOfDeath” }}
{{> afQuickField name=“amountPaid” data-mask=“Php 99,999.99” }}
{{> afQuickField name=“medical” }}
{{> afQuickField name=“partialPayment” data-mask=“Php 99,999.99” }}
{{> afQuickField name=“claimNumber” }}
{{/autoForm}}

the helper is taking care of orion, the feature that i want to implement is a custom event, it’s beyond’s orion core.

This change event is actually work until the console.log() line but on the last line i think i am missing something.

'change select[name=enrollmentId]': function(event, template) {
    var enrollmentId = $(event.target).val();
    console.log(enrollmentId);
    template.$('select[name=childrenId]').val(enrollmentId);
},

I can see the value of the enrollment id on the console once i selected but when i select on children all children from other enrollee/document is appearing.

Do you think i need a helper on this?