I'm trying to take a height given in feet and inches and convert it to inches (eg. 6'1" would be 73"). When I only have one select box (the feet box) I can successfully convert it to inches. But when I add the 'inches' variable and try to add it to the converted 'feet' variable nothing happens.
Here's the script:
<script type="text/javascript" language="javascript">
function Calculate() {
var feet = document.getElementById("feet").value;
var inches = document.getElementbyId("inches").value;
height = ((feet*12) + inches);
document.write ('This is your height in inches:<b> ' + height.toFixed(0) + '</b><br>');
}
</script>
And the HTML:
<div class="form">
Height:
<select id="feet">
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select>
<select id="inches">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
</select>
<br />
<input type="submit" value="Calculate" onclick="Calculate()" />
Thanks in advance