Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用循环将id添加到复选框_Javascript_Html_Node.js_Web_Ejs - Fatal编程技术网

Javascript 使用循环将id添加到复选框

Javascript 使用循环将id添加到复选框,javascript,html,node.js,web,ejs,Javascript,Html,Node.js,Web,Ejs,我使用NodeJS和express将JSON显示为HTML表。 现在表显示出来了,我想添加一个复选框列来跟踪用户选择的行。 因此,我在循环中添加了一个复选框,用于从JSON生成表。 但我不能使用循环变量向每个复选框添加id 如果有人能帮我解决这个问题,我真的很高兴 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Test</titl

我使用NodeJS和express将JSON显示为HTML表。 现在表显示出来了,我想添加一个复选框列来跟踪用户选择的行。 因此,我在循环中添加了一个复选框,用于从JSON生成表。 但我不能使用循环变量向每个复选框添加id

如果有人能帮我解决这个问题,我真的很高兴

    <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Test</title>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" type="text/css" href="/css/table.css">
 </head>
<body align="left">
 <form action="/results" method="post">
<div class="container">
<table class="table" align="left">
      <thead>
        <tr>
        <th>Download </th>
        <th>Title</th>
        <th>time </th>
        <th>seeds </th>
        <th> size </th>
        <th> provider </th>
        <th> link </th>
      </thead>


  <tbody>
      <% for (var i = 0; i < torrents.length; i++) { %>
        <tr>
          <td> <input type="checkbox" id=<%i%> > </td> <!-- the problematic line-->
          <td> <%= torrents[i].title%> </td>
          <td> <%= torrents[i].time%> </td>
          <td> <%= torrents[i].seeds%> </td>
          <td> <%= torrents[i].size%> </td>
          <td> <%= torrents[i].provider%> </td>
          <td> <%= torrents[i].link%> </td>
   </tr>
<% }%>
  </tbody>
</table>
</body>
</div>


<input type="submit" class="ghost-button" value="Download selected torrents to seedbox">
</form>
</html>

试验
下载
标题
时间
种子
大小
供应商
链接

您使用的您使用的
应该是
?您在其他PHP输出中正确地使用了
=
。哦,我的坏想法是,它只用于从服务器传递的变量,它将由服务器传递,因为您的循环正在服务器上运行。
应该是
?您在其他PHP输出中正确地使用了
=
。噢,我的坏想法是,它只用于从服务器传递的变量,它将由服务器传递,因为您的循环正在服务器上运行。