Yii2 how to call post function

In a Yii2 form I nee to trigger some code when things changed on a field I’m using onchange to do this

This is the kind of thing I need :


->dropDownList(Customer::getDataList(),

 array('prompt'=>Yii::t('app','select.customer'), 

'onchange'=>'$.post("index.php?

r=comptacust/selectedlists&id='.'"+$(this).val(), function(data) { $( 

"select#invoiceheader-comptacust_id" ).html(data) })', 

'onchange'=>'$.post("index.php?

r=pmtmode/selectedlists&id='.'"+$(this).val(), function(data) { $( 

"select#invoiceheader-pmtmode_id" ).html(data) })', 

'onchange'=>'$.post("index.php?

r=pmtcondition/selectedlists&id='.'"+$(this).val(), function(data) { $( 

"select#invoiceheader-pmtcondition_id" ).html(data) })', )); 



But the post function does work only 1 time (for pmtcondition)

What do I need to do so that I can do the 3 posts ?

Any help would be nice :)

It’s really hard to read what your code and what it’s doing. It appears that you are trying to do a dependent dropdown? If so, here is a wiki on how to achieve this. If not please clarify what you are tying to achieve.

Hello,

Thanks for your answer

My error was that I repeated onchange

but now with 3 post() functions in one onchange it works fine