您的位置:首页 > Web前端 > JavaScript

javascript实现对table的显示与隐藏

2011-11-17 11:42 423 查看
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!-- Header begin -->

<html>

<head>

<Script Language="JavaScript">

<!--

function getItem() {

var value =SelTest.options[SelTest.selectedIndex].value;

alert(value);

if(value == 1)

{

document.getElementByIdx("select_table1").style.display = "inline";

document.getElementByIdx("select_table2").style.display = "none";

}

if(value == 2)

{

document.getElementByIdx("select_table2").style.display = "inline";

document.getElementByIdx("select_table1").style.display = "none";

}

}

-->

</Script>

<Select name="SelTest" onchange="getItem()">

<option value=""> </Option>

<option value="1">1</Option>

<option value="2">2</Option>

</Select>
<table id = "select_table1" width = "100" border = "0" cellspacing = "0" cellpadding = "0" style = "display:inline">

<tr>

<td bgcolor = "#aabbcc" >table 1</td>

<tr>

</table>

<table id = "select_table2" width = "100" border = "0" cellspacing = "0" cellpadding = "0" style = "display:none">

<tr>

<td bgcolor = "#aabbcc" >table 2</td>

<tr>

</table>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: