I need this to take user input. Take the value and subtract one so that one of the 5 arrays can be called and printed. If 5 is chosen, all 5 arrays are printed; if 3 is chosen arrays 0 through 2 are printed.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML1.0Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test2</title>
</head>
<body>
<input type="button" onclick="dutyarray()" value="Click">To see my top<input type="number" id="counter"> job duties here</input>
<br />
<p id="task">Duties</p>
<script>
function dutyarray()
{
var x = document.getElementById('counter').value;
x = parseInt(x);
var duty= new Array();
duty[0] = "Operate Equipment";
duty[1] = "Check for Water Damage";
duty[2] = "Check for Mold";
duty[3] = "Follow Insurance Procedure";
duty[4] = "Restore";
while(x >= 0; x - 1)
{
document.getElementById('task').innerHTML = duty[x] + <br>;
}
}
</script>
xis greater than 0 before doing that loop! Oh, and usex--...while(x >= 0; x - 1)is not something while can do. Please look up “JavaScript array literals”.<br>probably needs to be in a string. To append, you could use+=, but the DOM is a much better solution.inputtag does not have an innerHTML attr, it is an open tag. 3. Read other comments.