I'm trying to create a content type where the fields are updated dynamically. For example, I could have two term reference fields: Manufacturer and Product Name. When the user chooses the manufacturer in the form, the Product Name field would only display products that have the selected Manufacturer.

Whats the best way to approach this?

3 Answers 3


You could write some ajax that onchange of the select drop down, you could populate the other list with values that you grab from the database.

   var options = get_values_from_database($(this).val());
   $.each(options, function(i, val){
     $('new-dropdown').append('<option value="'+val+'">'+val+'</option>');

This may be a lot of work, someone may have made a module to do this already.. But doing it the manual way can be loads of fun!

  • I'm trying to apply this to an add-content page. Where can I call the js so that it is only loaded on this specific page?
    – devnill
    Jul 16, 2012 at 21:24
  • You could create a custom module (if you don't have one already), and just drupal_add_js('Drupal.mymodule.contentDropDown();','inline'); on pages where you want the JS to load (wrap in if statement). Jul 17, 2012 at 18:46

There is Conditional fields module, but stable version is available only for D6.


I would do it with jquery.

  1. Create all possible fields for the content type
  2. Hide all the fields in your css (display:none)
  3. Unhide the fields with jquery depending on the value chosen.

Here is a nice howto to do that, don't know if it's the latest jquery and remember that you have to address the jquery object differently in drupal. I do it the ugly way ;).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.