简体   繁体   English

如何在HTML表格中添加复选框?

[英]How to add checkbox in html table?

I need to add a checkbox in a html table I know the usual method like 我需要在html表中添加一个复选框,我知道通常的方法是

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

My current code is 我当前的代码是

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>";

but this gives an error 但这给出了一个错误

You have missed some quotes 你错过了一些报价

please use this code 请使用此代码

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>";

It appears that you're missing a quote, also you can get rid of some of the quotes (and rows): 看来您缺少引号,也可以删除一些引号(和行):

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>";

No need of concatenations, just put single quotes outside as given in the example below: 不需要连接,只需将单引号放在下面的示例中即可:

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>';

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

相关问题 我如何向此复选框添加点击事件? (HTML 助手) - How could i add an on click event to this checkbox? (HTML Helpers) 我想在现有的复选框gridview表中添加新的复选框行,也想在数据库中添加该新的复选框行 - I want to add new checkbox rows in existing checkbox gridview table and also want to add that new checkbox row in database how will i do it 如何使用 Xamarin android 中的复选框将数据添加到表格布局 - How to add data to a table layout with checkbox in Xamarin android 如何在现有 HTML 文件的末尾添加表格? - How to add a table at the end of the existing HTML file? 如何在HTML中向现有表添加新行 - How to add a new row to existing table in HTML 如何在DataTable中添加复选框? - How to add checkbox in DataTable? 如何将JSon的html标签添加到html表 <td> 在角度4 - How to add html tag from JSon to html table <td>in angular 4 iTextSharp:在带有文本的表格单元格内添加复选框 - iTextSharp: Add checkbox inside table cell with text 如何禁用GridView中的HTML复选框 - How to disable the html checkbox in gridview 如何添加复选框(输入html控件),该复选框将动态显示在asp.net的数据表中? - How to add checkbox(input html control) which will be appear dynamically in datatable in asp.net?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM