daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Feb 11th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <div id="test">
  2.    <apex:selectList size="1" id="testvalue" value="{!testvalues}">
  3.       <apex:selectOptions value="{!testoptionnames}"/>
  4.    </apex:selectList>
  5.    <input type="button" id='selectButton'  class="buttonclass"/>
  6. </div>
  7.    
  8. public List<SelectOption> gettestoptionnames() {
  9.      List<SelectOption> options = new List<SelectOption>();
  10.      List<testobject__c> testnamelist = new List<testobject__c>();
  11.      testnamelist = [Select Id,Name FROM testobject__c];
  12.      options.add(new SelectOption('Select One','Select One'));
  13.       for (Integer i=0;i<testnamelist.size();i++)
  14.       {
  15.           options.add(new SelectOption(testnamelist[i].Name,testnamelist[i].Name));
  16.       }
  17.       return options;
  18.  
  19.     }
  20.    
  21. <div id="test">
  22.    <apex:selectList size="1" id="testvalue" value="{!testvalues}" styleclass="selCls">
  23.       <apex:selectOptions value="{!testoptionnames}"/>
  24.    </apex:selectList>
  25.    <input type="button" id='selectButton'  class="buttonclass" onclick="validatePicklistvalue()"/>
  26. </div>
  27. <script>
  28. function validatePicklistvalue(){
  29. var picklistVal = document.getElementsByClassName('selCls')[0].value;
  30.   if(picklistVal == 'Select One'){
  31.      alert('please select a value in picklist');
  32.    }
  33. }
  34. </script>
  35.    
  36. <div id="test">
  37.        <apex:selectList size="1" id="testvalue" value="{!testvalues}" styleclass="selCls">
  38.           <apex:selectOptions value="{!testoptionnames}"/>
  39.        </apex:selectList>
  40.    <apex:selectList size="1" id="testvalue2" value="{!testvalues1}" styleclass="selCls">
  41.           <apex:selectOptions value="{!testoptionnames1}"/>
  42.        </apex:selectList>
  43.        <input type="button" id='selectButton'  class="buttonclass" onclick="validatePicklistvalue()"/>
  44.     </div>
  45. <script>
  46.     function validatePicklistvalue(){
  47.     var picklistVal = document.getElementsByClassName('selCls');
  48.       if(picklistVal[0].value == 'Select One'){
  49.          alert('please select a value in picklist');
  50.        }
  51.        if(picklistVal[1].value == 'Select One'){
  52.          alert('please select a value in 2nd picklist');
  53.        }
  54.     }
  55.     </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top