Hi, is there a possibility to auto populate select inputs depending on previous choice from database on the new/edit record?
Like ajax request on change :)
Thanks, Jakub
Have a look at the dependent() code which I think will do what you are looking for (you have two selects and the values shown in the second should be dependent upon the first?).
dependent()
Allan
Yes, that is what I'll need, but still cant figure it out. Do you have any examples? This will simplify a lot for me :)
I know how to target an element which will call function like here:
editor.dependent( 'options', function ( val ) { return val === 'Simple' ? { hide: ['position', 'office', 'extn', 'start_date', 'salary'] } : { show: ['position', 'office', 'extn', 'start_date', 'salary'] }; } );
But I'm confused how to address the new select field and update it's select options, and how should it be formatted.
editor.dependent('area', function (val, data, callback) {
$.ajax({ url: '123.php', data: { id: editor.val('area') }, type: 'post', dataType: 'json', success: function (res) { editor.field('farm').update( res ); } }); });
This one worked for me, thanks
Data structure:
{
"name1": "val1", "name2": "val2"
}
Hi,
Good to hear you got it working :-)
Regards, Allan
It looks like you're new here. If you want to get involved, click one of these buttons!
Replies
Have a look at the
dependent()
code which I think will do what you are looking for (you have two selects and the values shown in the second should be dependent upon the first?).Allan
Yes,
that is what I'll need, but still cant figure it out. Do you have any examples? This will simplify a lot for me :)
I know how to target an element which will call function like here:
editor.dependent( 'options', function ( val ) {
return val === 'Simple' ?
{ hide: ['position', 'office', 'extn', 'start_date', 'salary'] } :
{ show: ['position', 'office', 'extn', 'start_date', 'salary'] };
} );
But I'm confused how to address the new select field and update it's select options, and how should it be formatted.
Thanks,
Jakub
editor.dependent('area', function (val, data, callback) {
This one worked for me, thanks
Data structure:
{
}
Hi,
Good to hear you got it working :-)
Regards,
Allan