[英]Javascript/XML/HTML Clear and rewrite
使用此Javascript代碼:
arrLocations = xmlHTTP.responseText.split("~");
for (i = 0; i < arrLocations.length; i++){
// Extract the info for this button.
strLocation = arrLocations[i];
arrLocation = strLocation.split(";");
// Populate the contents of this button.
elTemp = document.getElementById('loc' + arrLocation[0]);
if (arrLocation[2].length > 0)
elTemp.innerHTML = elTemp.innerHTML + '<br><span style="font-size: 12px; font-weight: bold;">' + arrLocation[2] + ' ' + arrLocation[3] + '</span><br><span style="font-size: 10px;"> (' + arrLocation[4] + ')' + '</span><br>';
else
elTemp.innerHTML = arrLocation[1];
}
我正在寫按鈕的內部...顯示名稱和日期等...像這個例子:
這是按鈕HTML:
<table align="center" cellpadding="3" cellspacing="3" border="0">
<tr>
<td width="30%" align="center" valign="middle" id="loc1" nowrap style="cursor: hand; font-size: 36px; border: 9px outset orangered;" class="bodyText" onClick="updateLocationTable(1);">Finesse</td>
<td width="5%" align="center" valign="middle" nowrap class="bodyText"></td>
<td width="30%" align="center" valign="middle" id="loc2" nowrap style="cursor: hand; font-size: 36px; border: 9px outset orangered;" class="bodyText" onClick="updateLocationTable(2);">Rework</td>
<td width="5%" align="center" valign="middle" nowrap class="bodyText"></td>
<td width="30%" align="center" valign="middle" id="loc3" nowrap style="cursor: hand; font-size: 36px; border: 9px outset orangered;" class="bodyText" onClick="updateLocationTable(3);">OP/Masking</td>
</tr>
<tr>
<td align="center" valign="middle" colspan="3" nowrap class="bodyText"> </td>
</tr>
</table>
我的問題是,每次調用此函數時,...不會清除按鈕中已有的內容,而只是覆蓋其頂部...在執行另一次重寫之前,如何清除按鈕HTML中的內容?
當我進行另一次添加時,它最終看起來像這樣:保留先前的寫操作,然后再次重寫,僅添加一個...。因此,如果記錄了A和B,則屏幕顯示A + B ...如果C嘗試登錄...保留A + B,然后重寫A + B並添加C,所以我們最終得到A + B + A + B + C
所有人都知道...我用一個簡單的location.reload()解決了這個問題
我將其放在按下按鈕時調用的函數中...這允許進行額外的寫入操作,但是還刷新了僅加載數據庫中內容的頁面,無論如何這都是正確的信息...我是基本上只是隱藏問題,但它可以滿足我的需求!
感謝所有有用的建議!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.