Select naming series based on group

I want to write custom script that will fill Series field(while creating new item) based on field in selected item group.
For now I did next:
Created all naming series I want to use.
Created field in item group doctype as select list.

Now I’m stuck with custom script.

frappe.ui.form.on('Item', {
refresh(frm) {

item_group(frm) {