0

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

Edited by diafol: Wrong forum no php to be seen

3
Contributors
4
Replies
24
Views
2 Years
Discussion Span
Last Post by JorgeM
0

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!

1

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);
  });
})

Edited by JorgeM

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.