diff --git a/foundation/www/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/dynamically-show-options-in-dropdown.md b/foundation/www/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/dynamically-show-options-in-dropdown.md new file mode 100644 index 00000000..e14377e5 --- /dev/null +++ b/foundation/www/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/dynamically-show-options-in-dropdown.md @@ -0,0 +1,16 @@ +# Dynamically Update Options in Select Field + +Lets say you have a field named state and another field named city. And you would like to limit options in city based on the values chosen in state field, you can write custom script as shown below. + + frappe.ui.form.on("DocType Name Here", "state", function(frm) { + if(frm.doc.state == "Karnataka") + { + set_field_options("city", ["Bangalore","Mysore"]) + } + else if(frm.doc.state == "Maharashtra") + { + set_field_options("city", ["Mumbai","Pune"]) + } + }); + + {next} diff --git a/foundation/www/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/index.txt b/foundation/www/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/index.txt index 2b497555..06e02297 100755 --- a/foundation/www/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/index.txt +++ b/foundation/www/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/index.txt @@ -8,3 +8,4 @@ restrict-user-based-on-child-record sales-invoice-id-based-on-sales-order-id update-date-field-based-on-value-in-other-date-field custom-button +dynamically-show-options-in-dropdown