Your problem is that all those variables that you declared using the
var keyword in your first function are *INVISIBLE* to any other function.
They are called "local variables".
If you want a "global variable" (one visible to all functions) you *can* just omit the
var keyword, but it's much better practice to declare them outside of any funciton.
So, for example:
Code:
var formDaysStaying;
var formSeason;
var formPropertyType;
function orderForm() {
formDaysStaying = document.getElementById("daysStaying").value;
formSeason = document.getElementById("season").value;
formPropertyType = document.getElementById("propertyType").value;
document.getElementById("FEE").value = "$" + today.toFixed(2);
document.getElementById("totalCost").value = "$" + today.toFixed(2);
document.getElementById("today").value = "$" + today.toFixed(2);
document.getElementById("due").value = "$" + due.toFixed(2);
}
...
What happens, though, if your second function gets called before the first one ever is invoked??
I think, as a safety measure, you might want to call the first function as the very first action in the second one.
Also... You have an
alert there in the second function, but even though you tell the user something is wrong, you go ahead and submit the <form>.
Finally, if you are calling your second function from either the <form onsubmit=...> or any <input type=submit onclick=...>, you have a problem.
****
Oh, and also: It's a really bad idea to have an
if that is *NOT* followed by { ... } to clearly denote what statements are going to be executed (or not) because of the
if.