function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SimrinSimrin 

Javascript not called if value is null

<script type="text/javascript">
    function call(id1,id2,id3){ 
        callAction(document.getElementById(id1).value,document.getElementById(id2).value,document.getElementById(id3).value); 
    }
</script>

 <apex:selectList size="1" value="{!wValue}" id="check1"
         onchange="call('{!$Component.check1}','{!$Component.check2','{!$Component.check3}';">
            <apex:selectOption itemValue="Select"/> 
            <apex:selectOptions value="{!lOptions}" />
</apex:selectList>
sometimes my value is null and the javascript is not called
Best Answer chosen by Simrin
BDatlaBDatla
Hi Simrin,

You mean the compenent deosn't exist sometime ? or Valus of the component will be null some time ?

function call(id1,id2,id3){
             var c1 ='';
             var c2 ='';
             var c3 ='';
             if(document.getElementById(id1) != null)
                  c1 =document.getElementById(id1).value;
       if(document.getElementById(id2) != null)
                  c2 =document.getElementById(id1).value;
       if(document.getElementById(id3) != null)
                  c3 =document.getElementById(id1).value;
       callAction(document.getElementById(id1).value,document.getElementById(id2).value,document.getElementById(id3).value);
      
}

Regards,
BD
 

All Answers

Sagar PareekSagar Pareek
May i know what are Check1,Check2 and check3?
SimrinSimrin
Check1, Check2, Check3 are selectList similar to check1.
They are id of selectList.

If any of the the value out of Check1, Check2, Check3 are null, then my javascript is not called and i cannot progress
BDatlaBDatla
Hi Simrin,

You mean the compenent deosn't exist sometime ? or Valus of the component will be null some time ?

function call(id1,id2,id3){
             var c1 ='';
             var c2 ='';
             var c3 ='';
             if(document.getElementById(id1) != null)
                  c1 =document.getElementById(id1).value;
       if(document.getElementById(id2) != null)
                  c2 =document.getElementById(id1).value;
       if(document.getElementById(id3) != null)
                  c3 =document.getElementById(id1).value;
       callAction(document.getElementById(id1).value,document.getElementById(id2).value,document.getElementById(id3).value);
      
}

Regards,
BD
 
This was selected as the best answer