Hi,
I have a problem with the function of managing the availability of items in the dropdown (select) - Compute function.
The problem is as follows:
Code with jQuery code can be found here: http://jsfiddle.net/amarcinkowski/W7NHK/25/
I have a reservation form, where I use the datepicker, where I have two dates boxes: the start and the end, and two select form fields with a list of available cities. Depending on the selected dates the script calculate the number of days.
If the number of days is less than 4, on one of the select lists of cities (the second - City2) changes the availability of active days and automatically selects the city selected in the first list (City1). So if we select on the first list city – Katowice for example, and the number of days is less than 4 on the second list script automatically marked the Katowice city and the others cities will be inactive (disabled).
The problem begins when the number of days is greater than 4 days. Both lists are fully active and you can choose any city, without restrictions. If you select different cities and then change the date, and number of days go down to 3 (for example) the whole script should recalculate values and set in the second window, the city which was chosen in first window (City1 = City2). Unfortunately, this does not happen. Additionally, in the second list, you can choose any city – all are active. The whole script is recalculating only if you select the city from the first list.
I know that is a little confusing, but for a few days I fight with this problem and I can’t implement the necessary changes.
I will be grateful for any help.