Hi all
I am trying to make a program where the user inputs information into the prompt boxes which is then displayed in a table. If anyone can help me out with where I am going wrong, it would be incredibly helpful
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<script>
//declaring variables
var jobtittle;
var employer;
var salary;
//repeating the prompts 5 times
for(var i=1;i<=5;i++){
//asks user for input for job title
jobtitle = prompt ("Please enter the job title for advertisement", " ");
//checks if prompt box is empty
if (jobtitle === " ") {
jobtitle=prompt ("Job title name not supplied", " ");
}
//asks user for employer
employer = prompt ("Please enter the employer name for advertisement", " ");
//checks if prompt box is empty
if (employer === " ") {
employer=prompt ("Employer name not supplied", " ");
}
//asks user for salary
salary = prompt ("Please enter the annual salary for advertisement", " ");
//checking salary is a valid number and prompting correct input if not
salary=parseInt(salary);
while(isNaN(salary)){
salary=prompt("Annual salary not supplied.", " ");
salary=parseInt(salary);
}
}
//table
document.write('<table>');
document.write ('<tr><th align="left"> Job Title </th>');
document.write('<th align="left"> Employer Name </th>');
document.write('<th align="left"> Annual Salary ($) </th> </tr>');
for(var i=0; i < jobtitle.length; i++)
{
document.write('<tr><td>' + jobtitle[i] + '</td></tr>');
}
for(var i=0; i < employer.length; i++)
{
document.write('<tr><td>' + employer[i] + '</td></tr>');
}
for(var i=0; i < salary.length; i++)
{
document.write('<tr><td>' + salary[i] + '</td></tr>');
}
document.write('</table');
</script>
</body>
</html>