I need the page to output a result once all the variables have been selected...
I am new to code and javascript so please don't grill me as I don't know where to begin in solving this one.
I need the page to output a result once all the variables have been selected...
I am new to code and javascript so please don't grill me as I don't know where to begin in solving this one.
"Have I referenced the Javascript files correctly on this html page?"
Yes, your JavaScript files are correctly referenced. Your css files aren't though (open the network tab of your chrome developer tools - or in any browser), you'll see http 404 responses (not found).
But I'm not sure your script works - well I can't say more since I don't know exactly what it's supposed to do ...
Usually scripts are stored in file on your web server, and reference is included to head tag like
<script type="text/javascript" src="your_script.js"></script>
You have to use that link to get more info Where should I put <script> tags in HTML markup?
Here is quick solution (it is not best one, but it works and is suitable for newcomers)
var theTemps = [18, 21, 16],
theWallUValues = [0.45, 0.6, 0.8],
theRoofUValues = [0.32, 0.6, 2],
theWindowUValues = [1.6, 0.6, 2],
theFloorUValues = [3.2, 6.4, 4.7],
condition_array = [false, false, false, false, false]; // one for each field
function result(){
alert('all are selected');
}
function check_if_all_are_full(){
// call result function if all elements in array are true
if (condition_array.every(function(element){return element;})){
result();
}
};
function i_am_selected(integer){
// update array and call check if all are selected
result[integer] = true;
check_if_all_are_full();
}
function setTemp(t) {
i_am_selected(0);
document.heatloss_calc.house_room_temp.value = theTemps[t];
}
function setHouseWallUValue(u) {
i_am_selected(1);
document.heatloss_calc.house_wall_u_value.value = theWallUValues[u];
}
function setHouseRoofUValue(u) {
i_am_selected(2);
document.heatloss_calc.house_roof_u_value.value = theRoofUValues[u];
}
function setHouseWindowUValue(u) {
i_am_selected(3);
document.heatloss_calc.house_window_u_value.value = theWindowUValues[u];
}
function setHouseFloorUValue(u) {
i_am_selected(4);
document.heatloss_calc.house_floor_u_value.value = theFloorUValues[u];
}
Also - it can be a good idea to make submit button inactive by default, and use result function to make it active (here is the link http://www.w3schools.com/jsref/prop_submit_disabled.asp)