Hi i am facing a problem.

please any body help me

   <script type="text/javascript">
$(function(){
 $("#timegap").change(function(){

  var totalreg=parseInt($("#totalreg").val());   // (500)
  var numberofcounselor=parseInt($("#couid").val()); //(8)
  var timegap=parseInt($("#timegap").val());  //(11)

  var appsperhour=Math.ceil(60/timegap);
  alert(appsperhour);
  });
})
</script>

The out put is without using ceil is 5.45. But using ceil i am getting 6. But in my project i ant 5.4 means get 5 and

5.6 means get 6. any body help me

out put is

Try using Math.round instead

Apologies I just realised I gave a php link - don't know why I did that. Fortunatley languages are so simillar that my answer is right anyway!

Its very difficult to understand what your actual question is, at least for me. What is it that you want the result to look like? a integer with no decimal places rounded to the nearest whole number?

If you would do something like this when you create your post, and try to write complete sentences, it would be a lot easier to figure out what you are doing and what the problem is.

I am assuming you have somethign like this. The dropdown is there just to generate the event, variables are assigned values manually in this example as you described above.

<select id="timegap">
 <option>A</option>
 <option>B</option>
</select>


$(function(){
 $("#timegap").change(function(){
    var totalreg = 500;
    var numberofcounselor = 8;
    var timegap = 11;
    var appsperhour = Math.round(60/timegap);  // returns 5
    var appsperhour = 60/timegap;              // returns 5.4545
    alert(appsperhour);
  });
})
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.