|
復制代碼 代碼如下:
// 設置FieldSet高度方法,支持IE瀏覽器、Firefox
// 參數1:pTableID,FieldSet內部div或table的id
// 參數2:pFieldSetID,FieldSet的ID
// 參數3:pImageID,圖片的ID,展開或收縮后更新圖片SRC
function FieldSetVisual( pTableID, pFieldSetID, pImageID )
{
var objTable = document.getElementById( pTableID ) ;
var objFieldSet = document.getElementById( pFieldSetID) ;
var objImage = document.getElementById( pImageID) ;
if( objTable.style.visibility == 'visible' )
{
objTable.style.visibility = 'hidden' ;
objFieldSet.style.height = "22px" ;
objImage.src="images/expand.png" ;
}
else
{
objTable.style.visibility = 'visible';
var heightFieldSet = parseInt( objFieldSet.style.height.substr(0,objFieldSet.style.height.length-2)) ;
var heightTable = parseInt( objTable.offsetHeight ) ;
objFieldSet.style.height = heightFieldSet + heightTable + "px" ;
objImage.src="images/constringency.png" ;
}
}
HTML中FieldSet代碼:
復制代碼 代碼如下:
<fieldset id="fset_ShipInportInfo">
<legend>
<img alt="展開或收縮" id="img_ShipInportInfo" src="images/constringency.png" src="images/constringency.png" onclick="FieldSetVisual('t_ShipInportInfo','fset_ShipInportInfo','img_ShipInportInfo')" />車船到廠記錄<span style="color: Red;" style="color: Red;">(已錄入/未錄入)</span></legend>
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="t_ShipInportInfo"
style="visibility: visible;" style="visibility: visible;">
<tr>
<td>
車船名:<span style="font-weight: bold;" style="font-weight: bold;">車皮 等 共50節</span>
</td>
<td>
車船到達時間:2009年5月9日 17時
</td>
<td>
來煤方式:<span style="font-weight: bold;" style="font-weight: bold;">鐵路</span>
</td>
<td>
煤炭來源:<span style="font-weight: bold;" style="font-weight: bold;">淮南</span>
</td>
</tr>
</tr>
</table>
</fieldset>
JavaScript技術:JavaScript設置FieldSet展開與收縮,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。