Javascript to pass value from one function to another function Onchange event

was developing application to calculate cuf where user selects one of the option in the drop down menu…
For example if user selects hour …Im generating two fields for date and time…after user enters date and time and changes to next field need to check minutes,so I’ve creating a function to check weather user as entered the time in multiples of 10 and the values are between 00-50…But how pass the value…

Below is my Html Code

    <label>CUF PERFORMANCE</label>
       <select id="select" name="options">
        <option>Select The Value</option>
        <option id="hourly" value="a">Hourly</option>
        <option id="daily" value="b">Daily</option>
        <option id="monthly" value="c">Monthly</option>
        <option id="yearly" value="d">Yearly</option> 
       </select><br/><br/>

Below Is my Javascript to populate date and time field

        var select=document.getElementById('select');
var wrappElement=document.getElementById('wrapper');

select.addEventListener('change',function(){
 if(select.value=='a'){
  var dateElement=document.createElement('input');
  dateElement.type='date';  
  wrappElement.appendChild(dateElement);
  var timeElement=document.createElement('input');
   timeElement.type='time';
   wrappElement.appendChild(timeElement); 
   function timecheck(timeElement);
      }
      } , false);

javascript Code to check minutes

    	  function timecheck(var time){
	  var allowed_values = new array("00","10","20","30","40","50");
	  var minute_check = time.split(':').pop();
	  for(var i=0;i<=allowed_values.length();i++)
	  {
		  if(allowed_values == minute_check)
		  {
             return true;
		  }
		  alert("minutes values must be between 00 - 50 and must be multiples of 10");
		  document.getElementById('input').value='';
		  	  return false;
	  }
  }

.
Below is jsfiddle link…not able to pass the value…

another link that was populating the fields…

Is this line correct in your function?

if(allowed_values == minute_check)

As allowed_values is an array, shouldn’t you be checking

if(allowed_values[i] == minute_check)

inside the loop?

Wow!! Very good.
Thank for coding !

@droopsnoot…Ive done that …sorry ive posted old jsfiddle link…Here is the updated link…still its not working …Im trying to pass the value of the variable timeElement to timecheck function…

@aeclubwoi555…what do u mean…??:expressionless:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.