当前位置: 首页 > 图文教程 > 网络编程 > Javascript > JavaScript设置FieldSet展开与收缩

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 JavaScript设置FieldSet展开与收缩


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 446 ::
收藏到网摘: n/a

JavaScript设置FieldSet展开与收缩实现代码。 JavaScript方法代码:
复制代码 代码如下:

// 设置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>