This is what I have so far but it doesn't even prompt the user, it shows a thin black line (which I think is the border)
<html>
<head>
<meta charset = "utf-8">
<title>Dynamically creating a table</title>
</head>
<body>
<table style = "width:100%" cellspacing="5" border="2">
<script type = "text/javascript">
var running = true; //boolean to determine if we should continue running
while(running) {
var i = 0;
var input; //variable that holds the input values
input = window.prompt("Please enter your product number then quantity sold, seperated by a comma. Hit Enter when you are done.");
var split;
var num1;
var num2;
if(input != "") {
split = input.split(',');
num1 = split[0];
num2 = 0;
if(split.length > 1) {
num2 = split[1].trim();
}
}
switch(num1) {
case 1:
// unimportant calculations
break;
case 2:
// unimportant calculations
break;
default:
document.writeln("<tr>");
document.writeln("<td>text</td>");
document.writeln("<td>text</td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln("<td>text1</td>");
document.writeln("<td>text2</td>");
document.writeln("<td>text3</td>");
document.writeln("</tr>");
running = false;
}
}
</script>
</table>
</body>
</html>
I tried including it in both the head and body, I also tried declaring the table tag in the script and outside the script.
var input[i];- execution of your script would stop at that line. If you open your browser's dev console and refresh the page you should see an error message about it. Also yourswitchstatement has incorrect syntax (and once you fix the switch syntax you're probably going to want to add somebreakstatements for each case).