I've made this table:
<button onclick="calc();">Display Results</button>
<table id='data' data-role="table" >
</table>
To take values from these sliders:
<form method="post">
<label for="points">Voltage (V)</label>
<input type="range" name="points" id="volt" value="0" min="0" max="1000" step="10">
</form>
<form method="post">
<label for="points">Minimum Resistance (Ω)</label>
<input type="range" name="points" id="resMin" value="50" min="100" max="1000" step="100">
</form>
<form method="post">
<label for="points">Maximum Resistance (Ω)</label>
<input type="range" name="points" id="resMax" value="50" min="100" max="1000" step="100">
</form>
And this function:
function calc()
{
var volt=document.getElementById("volt").value;
var resMin=document.getElementById("resMin").value;
var resMax=document.getElementById("resMax").value;
var table = document.getElementById("data");
var header = table.createTHead();
var row = header.insertRow(0);
row.insertCell(0).innerHTML = "Voltage (V)";
row.insertCell(1).innerHTML = "Resistance (Ω)";
row.insertCell(2).innerHTML = "Power (W)";
for (var i = 0; i<= ((resMax - resMin)/100); i++)
{
table.insertRow(i+1);
table.rows[i+1].insertCell(0);
table.rows[i+1].insertCell(1);
table.rows[i+1].insertCell(2);
table.rows[i+1].cells[1].innerHTML = resMin + i*100;
table.rows[i+1].cells[2].innerHTML = (Math.pow(volt,2)/resMin);
}
}
But, I get no errors, and when I click the button, nothing happens. The browser console is clean, there doesn't appear to be any syntax errors, and I can't seem to find a solution.
Full HTML:
<!DOCTYPE html>
<!--
Khalid Alzhrani
A00361007
Assignment #4
-->
<html>
<head>
<title>Chapter 4 - PE4</title>
<link rel="stylesheet"
href="css/jquery.mobile-1.4.5.min.css">
<script src="scripts/jquery-1.12.0.min.js">
</script>
<script src="scripts/jquery.mobile-1.4.5.min.js">
</script>
<script type='text/javascript' src='scripts/display.js'>
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div data-role ="header" data-theme="b" style="text-align:center;">
Electricity<br>Calculator</div>
<div data-role="content" class="ui-content">
<form method="post">
<label for="points">Voltage (V)</label>
<input type="range" name="points" id="volt" value="0" min="0" max="1000" step="10">
</form>
<form method="post">
<label for="points">Minimum Resistance (Ω)</label>
<input type="range" name="points" id="resMin" value="50" min="100" max="1000" step="100">
</form>
<form method="post">
<label for="points">Maximum Resistance (Ω)</label>
<input type="range" name="points" id="resMax" value="50" min="100" max="1000" step="100">
</form>
<button onclick="calc();">Display Results</button>
<table id='data' data-role="table" >
</table>
<div data-role = "footer" data-theme="b" style="text-align:center;">
<small>Power Display</small><br>
<small>Khalid Alzhrani - A00361007</small>
</div>
</div>
</body>

resMinorresMax?