Hi, I'm a newbie to JavaScript and i need help on one part of my code. I have 3 parallel arrays with the variables being id, name, and grade. I have to prompt a user to type in an id number and it will pull up the id, name, and grade associated with that id number. I've gotten the prompt and a while loop to make sure the entered ID is a number. But i'm not sure what to do from here. I need to use a for loop to pull up the info together.
Here's my code so far.
There are 5 values for each variable in the arrays. The name and grade variables are pulling up nothing.
Here's my code so far.
Code:
<script type="text/javascript"> var idnum=prompt("Please Enter ID",""); while(isNaN(idnum)){ alert("Sorry the entered ID is not a number. Please try again."); idnum=prompt("Please Enter ID",""); } for(var i=0; i<=4; i++){ } document.write("<table border='1'><tr>"); document.write("<td>ID:</td>"); document.write("<td>"+idnum+ "</td>"); document.write("<tr>"); document.write("<td>Work:</td>"); document.write("<td>"+name[i]+ "</td>"); document.write("<tr>"); document.write("<td>Grade:</td>"); document.write("<td>" +grade[i]+ "</td>"); document.write("</table></tr>");
Comment