dtng25909 2014-12-15 07:49
浏览 26

鼠标单击不会在JavaScript中触发多个操作

i got a doubt in my booking form.

i had created date picker & No.of adults and room type in it.

i'm calculating all no. of days using datepicker & getting no.of rooms based on no.of.adult input - 4person per room if no. of adult is more than 4 rooms will be changed to 2.

so what is the problem is i want to calculate the amount to be payed by mouse click events.

i'm having an function for no.of.adults code below:

function calc()
{
   var textValue1 = document.getElementById('rent_room').value;
   var textValue2 = document.getElementById('id_days').value;
   var textValue3 = document.getElementById('id_rooms').value;

   document.getElementById('total_id').value = textValue1 * textValue2 * textValue3;

   var textValue4 = document.getElementById('total_id').value;
   var textValue5 = document.getElementById('tax_id').value;

   document.getElementById('tax_id').value = textValue4 / 100 * 17.5; 
   document.getElementById('total_amount').value = ((+textValue4) + (+textValue5)).toFixed();
}

but if some one changes the value of no.of days (or) room type, the calculation is not updating. i have to click on no.of adults to carry on the calculation.

so i assigned same function like above to all buttons.

but it is not working..it is happening like this.. Steps to reproduce the problem.

  1. click no.of.days -> room type -> no.of .adults -> value calculated.

  2. change the value of days -> no.of days got incremented(but final value is not calculated)

  3. so click on the no.of.days again -> trigger works and final value is calculated.

  4. the value is updated. but again click on the button only makes it to calculate.

i need if i click on any button the value should be changed and at the same time using the new value the final amount should be calculated.

form link here: http://postlor.byethost7.com/booking/

form index page code link here: http://postlor.byethost7.com/booking/index.txt

kindly help me with the problem.

Thanks in Advance. :)

  • 写回答

1条回答 默认 最新

  • douqi4673 2014-12-15 08:11
    关注

    call your calc() function in both datepickers in onSelect event

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算