菜鸟100分求助JS下拉菜单的问题

JavaScript014

菜鸟100分求助JS下拉菜单的问题,第1张

function showsubmenu(sid)

{

/*

whichEl = eval("document.getElementById('"+"submenu" + sid+"')")

imgmenu = eval("document.getElementById('"+"imgmenu" + sid+"')")

if (whichEl.style.display == "none")

{

if (whichEl.style.display=='none') whichEl.style.display=''

else whichEl.style.display = 'none'

imgmenu.background="image/menuup.gif"

}

else

{

if (whichEl.style.display=='none') whichEl.style.display=''

else whichEl.style.display = 'none'

imgmenu.background="image/menudown.gif"

}

*/

//某一分类弹开,其它分类自动关闭

whichEl = eval("document.getElementById('"+"submenu" + sid+"')")

imgmenu = eval("document.getElementById('"+"imgmenu" + sid+"')")

var newsTD=document.getElementsByTagName("td")

var obj=whichEl

if(obj.style.display=="none")

{

for(i=8i<newsTD.lengthi++)

{

if(newsTD[i].id.indexOf("submenu")!=-1)

{

if (newsTD[i].style.display!="none")

{

newsTD[i].style.display = "none"

}

}

if(newsTD[i].id.indexOf("imgmenu")!=-1)

{

newsTD[i].background = "image/menudown.gif"

}

}

obj.style.display=""

imgmenu.background="image/menuup.gif"

}

else if(obj.style.display!="none")

{

obj.style.display="none"

imgmenu.background="image/menudown.gif"

}

}

</SCRIPT>

直接写了一下,不知道是不是你想要的,

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=UTF-8">

<title>Insert title here</title>

<script type="text/javascript">

function clickA(){

document.form1.textname.style.display=""

document.form1.selectname.style.display="none"

}

function clickB(){

document.form1.textname.style.display="none"

document.form1.selectname.style.display=""

}

</script>

</head>

<body>

<form name="form1" action="">

<select>

<option onclick="clickA()">A</option>

<option onclick="clickB()">B</option>

</select>

<input type="text" name="textname" style="display:none" >

<select name="selectname" style="display:none">

<option>A</option>

<option>B</option>

</select>

</form>

</body>

</html>