我正在尝试将 JQuery load() 中的数据附加到表中。虽然我能够成功地将数据附加到表中,但附加结果的格式未与表的其余部分一致。
表格的当前格式(附加后)
+---------------------------------------------------+
| Data |
-----------------------------------------------------
| Data | Data |
-----------------------------------------------------
| Data | Data |
-----------------------------------------------------
|Append data|Append data |
--------------------------
|Append data|Append data |
--------------------------
|Append data|Append data |
--------------------------
|Append data|Append data |
--------------------------
所需格式
+---------------------------------------------------+
| Data |
-----------------------------------------------------
| Data | Data |
-----------------------------------------------------
| Data | Data |
-----------------------------------------------------
| Append Data | Append Data |
-----------------------------------------------------
| Append Data | Append Data |
-----------------------------------------------------
| Append Data | Append Data |
-----------------------------------------------------
代码摘录:
<table id="edititemtable" border='1'>
<tr>
<td colspan='2'>Item Info</td>
</tr>
<tr>
<td>Select Category: </td>
<td>
<select id='changeitemcat' name='changeitemcat'></select>
</td>
</tr>
<tr>
<td>Select SubCategory: </td>
<td>
<select id='changeitemsubcat' name='changeitemsubcat'></select>
</td>
</tr>
<div id="details" name="details">
</div>
</table>
使用的 JQuery 的提取
$("#edititemtable").append($("#details").load('changeitem.php?cat='+cat+'&subcat='+subcat+'&item='+item));
.load() 文件的提取
while($extractdetails=$getitem->fetch(PDO::FETCH_ASSOC))
{
//Data is saved into the associated variables
echo"<tr>";
echo"<td>";
echo"Item Name";
echo"</td>";
echo"<td>";
echo"<input type='text' id='changeitemname' name='changeitemname' value=$itemname size='30' maxlength='50' />";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td>";
echo"Item Price";
echo"</td>";
echo"<td>";
echo"<input type='text' id='changeitemprice' name='changeitemprice' value=$itemprice size='7' maxlength='7' />";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td>";
echo"Item Info";
echo"</td>";
echo"<td>";
echo"<textarea class='textarea' id='changeiteminfo' name='changeiteminfo' col='10' rows='10' maxlength='300' >$iteminfo</textarea>";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td>";
echo'<form id="changeitem" name="changeitem" method="POST" action="">';
echo"<input type='hidden' id='changeitemid' name='changeitemid' value='$itemid' />";
echo"<input type='submit' id='changeitemsubmit' name='changeitemsubmit' value='Save Changes' />";
echo"</form>";
echo"</td>";
echo"</tr>";
}
问题
我如何获得所需的格式?
为什么附加数据被强制进入其中之一?
解决方案:
<table id="edititemtable" border='1'>
<tr>
<td colspan='2'>Item Info</td>
</tr>
<tr>
<td>Select Category: </td>
<td>
<select id='changeitemcat' name='changeitemcat'></select>
</td>
</tr>
<tr>
<td>Select SubCategory: </td>
<td>
<select id='changeitemsubcat' name='changeitemsubcat'></select>
</td>
</tr>
<tr>
<td colspan="2" id="details" name="details">
</td>
</tr>
</table>
Ps 我目前正在使用 HTML 5 和 PHP