我需要创建表头。如何使用document.write编写。我尝试使用<thread>
代码,但它无效?
<script type="text/javascript">
function btnCallWCF_onclick() {
Service.getproprttydatasdata(onSuccess);
}
function onSuccess(response) {
debugger;
document.write('<table border="1" cellspacing="1" cellpadding="5"><thead><tr>Address</tr><tr>Address</tr><tr>Address</tr>')
for (i = 0; i < response.length; i++) {
document.write('<tr>')
document.write('<tr>' + i + '</td>')
document.write('<td>' + response[i].Address + '</td>')
document.write('<td>' + response[i].Address + '</td>')
document.write('<td>' + response[i].Address + '</td>')
document.write('</tr>')
}
}
</script>
答案 0 :(得分:0)
尝试以下方法:
<script type="text/javascript">
function btnCallWCF_onclick() {
Service.getproprttydatasdata(onSuccess);
}
function onSuccess(response) {
debugger;
document.write('<table border="1" cellspacing="1" cellpadding="5"><thead><tr><th>Address</th><th>Address</th><th>Address</th><th>Address</th></tr></thead>'); // There is 1 row with 3 headings.
for (i = 0; i < response.length; i++) {
document.write('<tr>')
document.write('<td>' + i + '</td>') // Changed <tr> to <td>
document.write('<td>' + response[i].Address + '</td>')
document.write('<td>' + response[i].Address + '</td>')
document.write('<td>' + response[i].Address + '</td>')
document.write('</tr>')
}
}
</script>