i want to redirect to a specific tab break when the “example” checkbox is checked
frappe.ui.form.on('MyDocType', {
refresh: function(frm) {
frm.fields_dict['checkbox_example'].$wrapper.on('change', 'input[type="checkbox"]', function() {
if ($(this).is(":checked")) {
console.log("Checkbox checked!"); // Log to ensure the checkbox check is detected
// Switch to the "next tab"
$('a[href="#mydoctype-next_tab"]').tab('show');
}
});
}
});
$(‘a[href=“#mydoctype-next_tab”]’).tab(‘show’);
what is next_tab? from this line of code
Name of the tab break, find it on the form view via its URL when you hover over the tab
this code is not working
Hi @neha:
Try this:
frappe.ui.form.on('MyDoctype', {
checkbox_example(frm) {
if (frm.doc.checkbox_example) {
frm.scroll_to_field("first_field_of_your_tab")
}
}
});
Hope this helps.
Thank you it works