Want to filter field based on the other field

want to filter room no based on the type of the room i select.types of room is a drop down but in room no its showing all the rooms i created. so i need to filter based on the type of room using codes

frappe.ui.form.on("doctype name", "onload", function(frm) {
    cur_frm.set_query("room_no", function() {
        return {
            "filters": {
                "type_of_room": frm.doc.type_of_room
            }
        };
    });
});

its not working.

share your script here…

frappe.ui.form.on(“paid guest”, “onload”, function(frm) {
cur_frm.set_query(“room_no”, function() {
return {
“filters”: {
“types_of_room” : frm.doc.type_os_room,
“vacancy”: ‘yes’

        }
       
    };
});

});

frappe.ui.form.on(“paid guest”, “before_submit”, function(frm, cdt, cdn) {
frappe.call({
“method”: “frappe.client.set_value”,
“args”: {
“doctype”: “rooms”,
“name”: cur_frm.doc.room_no,
“fieldname”: “vacancy”,
“value”: “no”
}
});
})

this code is working…thanks for your idea