Hi guys so i am trying to complete a small task of helping the user pick the right ski size, So they would enter there age and height and what kind of ski's they would get, so freestyle or classic and it would calculate the length of the skis. Now i figured out how to do it with age and height when they enter it. So i went by :
1-4 years: body length + 0 cm.
5-8 years: body length + 10 cm
9-12 years: body length + 15 cm etc etc
That part works fine. But what i am trying to do now is when the user picks classic it adds an extra 10cm on to the final size and when they pick freestyle it adds on an extra 20cm . However this part i am not to sure how to accomplish and need help on.
HTML:
<form name="sizeForm">
Age: <input type="text" name="age" size="10"><br />
Height: <input type="text" name="height" size="10"><br />
<select name="typeski" class="select" id="name" autocomplete="off" placeholder="Type of ski" >
<option value="" disabled selected hidden>Please Select Type Of Skis. . . . . . .</option>
<option value="0">Classic</option>
<option value="1">Freestyle</option>
</select>
<input type="button" value="Calculate Size" onClick="finalsize()"><br />
Your Ski Size: <input type="text" name="ski" size="10"><br />
<input type="reset" value="Reset" />
</form>
js:
function finalsize() {
var age = parseInt(document.sizeForm.age.value)
var height = parseInt(document.sizeForm.height.value)
var typeski = parseInt(document.sizeForm.typeski.value)
if (age > 0 && height > 0) {
var size = height;
if (age > 1 && age <= 4) size += 0;
else if (age >= 5 && age <= 8) size += 10;
else if (age >= 9 && age <= 12) size += 15;
document.sizeForm.ski.value = size;
}
else {
alert("Please Fill in everything correctly")
}
}
Hopefully after this has been fixed i will try and make this into a vue.js app , as it seems to be better etc but for now trying to solve this
Thanks again