5

I have a webform in D7 where I want the user to select a value from a dropdown list. These values I want to be dynamically updated from a view. How can I do this?

I found the webform viewreference module, but it's D6. There is a d7 port that someone made using coder, but, like author notes, I get an error when I try to view the form with the view reference webform component.

Are there any solutions out there?

4

Take a look at the sandbox project Webform Views Select.

This module will let you populate a webform select component with data from a view.

1

You need to write your own module with a .js file. You have to make a rfi form for that and through you js file take the values.

Suppose on your site you have to select a country and based on that country different values like course, SiteID,AccountID and campaignID need to be selected.

In .js file you have to do:

(function ($) {
  Drupal.behaviors.highwire_article_nav = {
    attach: function (context, settings) {
      var campus_settings = $.parseJSON(Drupal.settings.settings_campus.campus_data);
      $('select#edit-submitted-occupation').find('option').remove();
      $('select#edit-submitted-occupation').append($('<option>', {
        value: '- Select -',
        text : '- Select -'
      }));
      $('select#edit-submitted-country').change(function(e){
          var campus = $(this).val().toLowerCase();
          var campus_config = campus_settings[campus];
          var campus_courses = campus_config.courses
          $('[name="submitted[siteid]"]').attr('value', campus_config.siteID);
          $('[name="submitted[campaignid]"]').attr('value', campus_config.campaignID);
          $('[name="submitted[accountid]"]').attr('value', campus_config.accountID);
        $('select#edit-submitted-occupation').find('option').remove();
          $.each(campus_courses, function(index) {
            $('select#edit-submitted-occupation').append($('<option>', {
            value: campus_courses[index],
            text : campus_courses[index]
          }));
        });
      });
    }
  }
}(jQuery));

In the rfi form give the values like :

{"country_name":{"course_name":{"0":"Course_name_1","1":"Course_name_2"},"campaignID":"value_of_campaign_ID" , "siteID":"value_of_site_ID" ,"accountID":"value_of_account_ID"}} and so on.
-1

EVA might work for that, however I haven't used it in this scenario.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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