简体   繁体   English

鼠标单击不会触发JavaScript中的多个动作

[英]Mouse click not triggering multiple actions in 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. 使用日期选择器的天数,并根据成人输入的数量获取房间数-如果没有,则为每个房间4人。 of adult is more than 4 rooms will be changed to 2. 成人超过4个房间将更改为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/ 此处的表单链接: http : //postlor.byethost7.com/booking/

form index page code link here: http://postlor.byethost7.com/booking/index.txt 表单索引页面代码链接在这里: http : //postlor.byethost7.com/booking/index.txt

kindly help me with the problem. 请帮助我解决这个问题。

Thanks in Advance. 提前致谢。 :) :)

在onSelect事件的两个日期选择器中调用您的calc()函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM