2

我需要在 html 表中添加一个复选框,我知道通常的方法,例如

    <td>  
        <input type="checkbox" name ="chk1" />  
    </td>

我目前的代码是

string html=""; 
html += "<table>";
html += "<tr><th>" + "A" + "</th><th>" + "B" + "</th><th>" + "C" + </th></tr>";
html += "<tr><td>" + "0" + "</td><td>" + "1" + "</td><td>" + "2" + </td></td>+"<input type="checkbox" name ="chk1" /> "  +</td>  </tr>"; 
html += "</table>";

但这给出了一个错误

4

3 回答 3

3

你错过了一些报价

请使用此代码

string html=""; 
html += "<table>";
html += "<tr><th>" + "A" + "</th><th>" + "B" + "</th><th>" + "C" + "</th></tr>";
html += "<tr><td>" + "0" + "</td><td>" + "1" + "</td><td>" + "2" + "</td></td>"+"<input type='checkbox' name ='chk1' /> "  +"</td>  </tr>"; 
html += "</table>";
于 2013-01-23T05:20:19.947 回答
2

看来您缺少引号,您也可以删除一些引号(和行):

string html=""; 
html += "<table>";
html += "<tr><th>A</th><th>B</th><th>C</th></tr>";
html += "<tr><td>0</td><td>1</td><td>2</td></td><input type=\"checkbox\" name =\"chk1\" /></td></tr>"; 
html += "</table>";
于 2013-01-23T05:23:21.520 回答
1

不需要连接,只需将单引号放在外面,如下例所示:

string html = ''; 
html += '<table>';
html += '<tr><th>A</th><th>A</th><th>C</th></tr>';
html += '<tr><td>0</td><td>1</td><td>2</td></td><input type="checkbox" name ="chk1"  /></td></tr>'; 
html += '</table>';
于 2013-01-23T05:25:16.280 回答