简体   繁体   中英

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. 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. :)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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