Inserting individual values from an array into a table cell

I have created a table using a for loop in my code and have various variables in multiple arrays. I want to be able to put the values from the array individually into each table cell going down in a column. For code I have this: function tableCreate() { for (rownum = 1; rownum <= 7; rownum++) { document.write(""); for (colnum = 1; colnum <= 7; colnum++) { if (rownum == 1 + colnum == 1) { document.write("" + id[0] + ""); } } document.write(""); } } var id = new Array("1022", "1112", "1230", "554", "1355", "1600"); var title = new Array("Prof.", "Prof.", "Prof.", "Prof.", "Asst. Prof.", "Asst. Prof."); var name = new Array("Catherine Adler", "Michael Li", "Maria Sanchez", "Robert Hope", "Wayne Li", "Kate Howard"); var position = new Array("Department Chair", "Asst. Chair", "TA Supervisor"); var er = new Array(2, 3, 1, 2, 1, 3); var yoe = new Array(18, 12, 10, 23, 8, 5); var cs = new Array(85000, 70000, 62000, 55000, 50000, 45000); The above code is all part of an external JavaScript document. I tryed using if statements to produce what I wanted but that failed. Now I'm lost and some help would be appreciated. To reitterate, I want to get say this array: var id = new Array("1022", "1112", "1230", "554", "1355", "1600"); into a table column and have each variable in that array take a cell in that column.
just to check, you want each row to contain an id, title, name, position, er, yoe, cs in that order?

以上就是Inserting individual values from an array into a table cell的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏