Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Main (required)
  • Sub1 (optional)
  • Sub2 (optional)

Image Added

The Sub1 list will only be displayed when the value 'One' is selected in the Main list, Sub2 list only when the value is 'Two'.

...

Code Block
languagejs
collapsetrue
// Enter your fieldnames here:
var mainListName = 'Main';
var subListOneName = 'Sub1';
var subListTwoName = 'Sub2';
var selectedOptionForSubListOne = 'One';
var selectedOptionForSubListTwo = 'Two';

// Don't change the code below this line
var tempoList = '.tempoStaticList';
var mainList = 'popup_Main' + mainListName + '_';
var subListOne = 'popup_Sub1_'; var+ subListTwosubListOneName =+ 'popup_Sub2_';
var selectedOptionForSubListOnesubListTwo = 'Onepopup_'; var+ selectedOptionForSubListTwosubListTwoName =+ 'Two_';

AJS.$(document).ready(function() {
  AJS.$('#time-popup').live('focus', function() {
    AJS.$('.tempoStaticList').each( function(index, item) {
      if (AJS.$(item).attr('id') != mainList) {
         AJS.$(this).parent().hide();
      }
    });
  AJS.$(tempoList + '[id$="' + mainList + '"').live('change', function() {
    if (AJS.$(this).val() == selectedOptionForSubListOne) {
      AJS.$('.tempoStaticList').each( function(index, item) {
        if (AJS.$(item).attr('id') == mainList || AJS.$(item).attr('id') == subListOne) {
	      AJS.$(item).parent().show();
        } else {
          AJS.$(item).parent().hide();
        }
      });
    } else if (AJS.$(this).val() == selectedOptionForSubListTwo) {
      AJS.$('.tempoStaticList').each( function(index, item) {
        if (AJS.$(item).attr('id') == mainList || AJS.$(item).attr('id') == subListTwo) {
	      AJS.$(item).parent().show();
        } else {
          AJS.$(item).parent().hide();
        }
      });
    } else {
      AJS.$('.tempoStaticList').each( function(index, item) {
        if (AJS.$(item).attr('id') == mainList) {
	      AJS.$(item).parent().show();
        } else {
          AJS.$(item).parent().hide();
        }
      });
    }
  });
  });
});

...