Question : How to trigger Ajax after second option has been selected

I've made this booking form (see the attached image), that uses Ajax to update the total price based on arrival date, departure date and number of guests. It's already working like it should, except for that the function call for getting the price shouldn't trigger until the departure date has been selected like it's doing now.

I have onchange="showPrice(this.value)" on both inputs, and I don't want to take it off the arrival date, because the user should still be able to change that after selecting it the first time.

What are the possible solutions for stopping the total price from updating itself prematurely?
 
screenshot of the form
324737
 

Answer : How to trigger Ajax after second option has been selected

Test the value of departure field before doing or not your ajax call :



1:
2:
3:
4:
5:
function showPrice(x) {
   if(document.getElementById("departure").value.length!=0) {
   	alert("ajaxcall start")!
   }
}
Random Solutions  
 
programming4us programming4us