繁体   English   中英

使用innerHTML将单元格数据写入HTML表

[英]Write cell data to a HTML table using innerHTML

我在将下面的最终函数displayLetter(a,b,c,d,e,f,g)放在一起并在array中将变量和变量Test()中的变量写入innerHTML中时遇到麻烦。 我知道我需要使用.length并确定需要多少个单元格。 W3C到现在为止还只有我。 谢谢您的帮助!

 <html>
   <head>
     <title>
     </title>
     <script>
     </script>
   </head>
   <body>
     <h1>TEST THIS SCRIPT</h1>
     <table border="1">
      <tr>
       <th>A</th>
       <th>B</th>
       <th>C</th>
       <th>D</th>
       <th>E</th>
       <th>F</th>
       <th>G</th>
      </tr>
     <a href="add data" id="reload">Add Employee</a>
   </body>
 <html>

我的JS:

 function addData()
 {
    var testarray = new Array();
    testarray[0] = window.prompt("Enter a letter", "z");
    variableTest(x, y);
    displaySalary(a, b, c, d, e, f, g);
 }


 function variableTest(x, y)
 {
    a=1;
    b=2;
    c=3;
    d=4;
    e=5;
 }


 displayLetter(a, b, c, d, e, f, g)
 {
    // Code to write the variables to the table 
 }

我不太确定您要做什么,但是弹出的内容很少。 我建议您声明var testarray = new Array(); 任何功能之外。 然后在
function addData()
{
testarray.push (window.prompt("Enter a letter"));
}

variableTest()应该做什么?

调用addDate时是否应该将提示的文本添加到该表的单元格中?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM