DependentPicklistVFpage


SUBMITTED BY: Guest

DATE: Jan. 22, 2014, 12:09 p.m.

FORMAT: Text only

SIZE: 2.3 kB

HITS: 4666

  1. <apex:page controller="DependentPicklistController">
  2. <apex:sectionHeader subtitle="Dependent Picklist Demo" title="Aslam Bari"/>
  3. <apex:includeScript value="{!$Resource.jquery}"/>
  4. <script>
  5. function prepareList(parent,child,isSubselectOptional){
  6. $("body").append("<select style='display:none' id='"+parent+child+"'></select>");
  7. $('#'+parent+child).html($("#"+child+" option"));
  8. $('#'+child).html("<option> — </option>");
  9. $('#'+parent).change(function(){
  10. var parentValue = $('#'+parent).attr('value');
  11. $('#'+child).html($("#"+parent+child+" .child_"+parentValue).clone());
  12. if(isSubselectOptional) $('#'+child).prepend("<option> — Select — </option>");
  13. });
  14. }
  15. $(function() {
  16. prepareList('accountList','contactList', false);
  17. });
  18. </script>
  19. <apex:form>
  20. <apex:pageBlock>
  21. <apex:pageBlockSection columns="1">
  22. <apex:pageBlockSectionItem>
  23. <apex:outputLabel value="Account" />
  24. <apex:outputPanel>
  25. <select id="accountList" size="1">
  26. <option value="">-Select-</option>
  27. <apex:repeat value="{!accounts}" var="acc">
  28. <option value="{!acc.Id}">{!acc.Name}</option>
  29. </apex:repeat>
  30. </select>
  31. </apex:outputPanel>
  32. </apex:pageBlockSectionItem>
  33. <apex:pageBlockSectionItem>
  34. <apex:outputLabel value="Contact" />
  35. <apex:outputPanel>
  36. <select id="contactList" size="1">
  37. <apex:repeat value="{!contacts}" var="con">
  38. <option class="child_{!con.accountid}" value="{!con.Id}">{!con.Name}</option>
  39. </apex:repeat>
  40. </select>
  41. </apex:outputPanel>
  42. </apex:pageBlockSectionItem>
  43. </apex:pageBlockSection>
  44. </apex:pageBlock>
  45. </apex:form>
  46. </apex:page>

comments powered by Disqus