Hi,

I am trying to write a module and it is an implementation of hook_form_alter. I created a new content type having 2 nodereference fields. What I want to do is make the second field show a different set of values depending on the user's selection in the first field. Let's say, I pick a city in the first field, then the second field should show a set of store outlets located in that city. If I pick another city, it should show a different set of stores in the second field. To achieve this, I need to create a some sort of an event handler. How can I do this?

If you know any modules that have been written already that can achieve this please do point me in the right direction. Or perhaps some documentation that may be related to this issue.

Any help will be greatly appreciated.

Thank you!

Cris

Comments

artatum’s picture

dont know if this can apply to D6, but this page is full of info about 'dynamic dropdown' :
http://drupal.stackexchange.com/questions/10112/dynamic-select-list-in-the-form-dependent-dropdown

jaypan’s picture

The hierarchical select module can do this. Either that or you can code your own #AHAH functionality.

Contact me to contract me for D7 -> D10/11 migrations.

artatum’s picture

If it needs to ask the database, I imagine AJAX is required, rather than AHAH. Dont you agree?

jaypan’s picture

#AHAH is Drupal 6 Ajax for forms. Using your own AJAX implementations will not work with Drupal forms (or rather it will work, but your form submission will then fail).

Contact me to contract me for D7 -> D10/11 migrations.

draftbeer80’s picture

Hi guys, thanks for your help. After days of research, I just found that there's no easy way to do this, so I have resorted to developing a module using AHAH.

Regards,
Cris

jaypan’s picture

Personally, that's how I'd do it, but be warned, figuring out #AHAH in D6 is not for the faint of heart. In fact, it's a real headache. If you find yourself running into a brick wall, try the module I mentioned earlier. Or, try the AHAH Helper module, it will make your AHAH callback easier.

Contact me to contract me for D7 -> D10/11 migrations.