<p>I would write a custom fieldtype (<a href="http://buildwithcraft.com/docs/plugins/field-types" rel="nofollow">http://buildwithcraft.com/docs/plugins/field-types</a>) with two selects. Makes sense to make it as one field if they are dependent of eachother.</p>

<p>Just store the field as json (AttributeType::Mixed) and inject your own javascript in the fields <code>getFieldHtml()</code></p>

CC BY-SA 3.0
2015-07-23T12:25:49.563Z
2015-07-23T12:25:49.563Z
fuling
<p>Instead of building a custom fieldtype, you could just connect two standard dropdown menus with some custom JavaScript. The easiest way to do that would probably be via the <a href="https://github.com/lindseydiloreto/craft-cpjs" rel="nofollow">Control Panel JS</a> plugin.</p>

<p>Fortunately, the control panel already uses jQuery, so you wouldn't need much JS to tie the two fields together.</p>

CC BY-SA 3.0
2016-03-14T05:49:51.233Z
2016-03-14T05:49:51.233Z
Lindsey D
<p>I'm looking to change a select fields options with the onChange event from another select fields chosen option. Obviously this can be done with js on the frontend as per <a href="https://craftcms.stackexchange.com/questions/4779/tie-two-select-fields-together-based-on-category-and-subcategory">this post</a> but has anyone done this for the control panel? I imagine it will need to be done via a fieldType plugin, but wondered if anything already exists for this type of functionality before I attempt to build something.</p>

CC BY-SA 3.0
2015-07-23T10:04:42.303Z
Do you already have a plugin and fieldType where you want to do this, or do you mean "this one built-in selectField is connected to this other built-in selectField?
fuling
CC BY-SA 3.0
2015-07-23T12:16:53.543Z
Could be either. If there is a way to connect select fields in craft already then great where can I find the documentation for it. If not then I would be looking at a plugin to do this.
Lettie
<field><fieldtypes><custom-fieldtype><custom-field>
Populate or change the selection options in one field based on selected option in another field in the CP
# Populate or change the selection options in one field based on selected option in another field in the CP

(Asked by: username_0 on 2015-07-23)

I'm looking to change a select fields options with the onChange event from another select fields chosen option. Obviously this can be done with js on the frontend as per [this post](https://craftcms.stackexchange.com/questions/4779/tie-two-select-fields-together-based-on-category-and-subcategory) but has anyone done this for the control panel? I imagine it will need to be done via a fieldType plugin, but wondered if anything already exists for this type of functionality before I attempt to build something.

**Tags:** field, fieldtypes, custom-fieldtype, custom-field
> **Comments:**
> **username_1**: Do you already have a plugin and fieldType where you want to do this, or do you mean "this one built-in selectField is connected to this other built-in selectField?  
> **username_0**: Could be either. If there is a way to connect select fields in craft already then great where can I find the documentation for it. If not then I would be looking at a plugin to do this.  

---

## 2 answers

### Answer by username_1 on 2015-07-23. Score: 2

I would write a custom fieldtype (<http://buildwithcraft.com/docs/plugins/field-types>) with two selects. Makes sense to make it as one field if they are dependent of eachother.

Just store the field as json (AttributeType::Mixed) and inject your own javascript in the fields `getFieldHtml()`


---

### Answer by username_2 on 2016-03-14. Score: 1

Instead of building a custom fieldtype, you could just connect two standard dropdown menus with some custom JavaScript. The easiest way to do that would probably be via the [Control Panel JS](https://github.com/lindseydiloreto/craft-cpjs) plugin.

Fortunately, the control panel already uses jQuery, so you wouldn't need much JS to tie the two fields together.


---

