请哪位高手帮我把下面的VBScript改成javascript,在下感激不尽!

ronghuan 2002-12-10 10:42:55
<script language="VBScript">
function display1(num)
dim imagename
dim name
dim total
if(num<10) then
if document.all("subtree"+chr(48+num)).style.display="none" then
document.all("subtree"+chr(48+num)).style.display=""
document.all("image"+chr(48+num)).src="image/t_sub.gif"
document.all("img"+chr(48+num)).src="image/open.gif"
else
document.all("subtree"+chr(48+num)).style.display="none"
document.all("image"+chr(48+num)).src="image/t_plus.gif"
document.all("img"+chr(48+num)).src="image/close(1).gif"
end if
end if
if(num>9) then
if document.all("subtree"+chr(49)+chr(48+num-10)).style.display="none" then
document.all("subtree"+chr(49)+chr(48+num-10)).style.display=""
document.all("image"+chr(49)+chr(48+num-10)).src="image/t_sub.gif"
document.all("img"+chr(49)+chr(48+num-10)).src="image/open.gif"
else
document.all("subtree"+chr(49)+chr(48+num-10)).style.display="none"
document.all("image"+chr(49)+chr(48+num-10)).src="image/t_plus.gif"
document.all("img"+chr(49)+chr(48+num-10)).src="image/close(1).gif"
end if
end if
end function
</script>
...全文
33 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ronghuan 2002-12-10
  • 打赏
  • 举报
回复
在下真是佩服啊!
感谢!
希默软件 2002-12-10
  • 打赏
  • 举报
回复
就一个if语句的转换,还有Chr(charcode)换成String.fromCharCode(49),很简单啊,自己解决吧
qiushuiwuhen 2002-12-10
  • 打赏
  • 举报
回复
try

<script>
function display1(num){
var imagename
var name
var total
if(num<10){
if(document.all("subtree"+String.fromCharCode(48+num)).style.display=="none"){
document.all("subtree"+String.fromCharCode(48+num)).style.display=""
document.all("image"+String.fromCharCode(48+num)).src="image/t_sub.gif"
document.all("img"+String.fromCharCode(48+num)).src="image/open.gif"
}else{
document.all("subtree"+String.fromCharCode(48+num)).style.display="none"
document.all("image"+String.fromCharCode(48+num)).src="image/t_plus.gif"
document.all("img"+String.fromCharCode(48+num)).src="image/close(1).gif"
}
}
if(num>9){
if(document.all("subtree"+String.fromCharCode(49)+String.fromCharCode(48+num-10)).style.display=="none"){
document.all("subtree"+String.fromCharCode(49)+String.fromCharCode(48+num-10)).style.display=""
document.all("image"+String.fromCharCode(49)+String.fromCharCode(48+num-10)).src="image/t_sub.gif"
document.all("img"+String.fromCharCode(49)+String.fromCharCode(48+num-10)).src="image/open.gif"
}else{
document.all("subtree"+String.fromCharCode(49)+String.fromCharCode(48+num-10)).style.display="none"
document.all("image"+String.fromCharCode(49)+String.fromCharCode(48+num-10)).src="image/t_plus.gif"
document.all("img"+String.fromCharCode(49)+String.fromCharCode(48+num-10)).src="image/close(1).gif"
}
}
}
</script>

ronghuan 2002-12-10
  • 打赏
  • 举报
回复
<script language="VBScript">
function display1(num)
dim imagename
dim name
dim total
if(num<10) then
if document.all("subtree"+chr(48+num)).style.display="none" then
document.all("subtree"+chr(48+num)).style.display=""
document.all("image"+chr(48+num)).src="image/t_sub.gif"
document.all("img"+chr(48+num)).src="image/open.gif"
else
document.all("subtree"+chr(48+num)).style.display="none"
document.all("image"+chr(48+num)).src="image/t_plus.gif"
document.all("img"+chr(48+num)).src="image/close(1).gif"
end if
end if
if(num>9) then
if document.all("subtree"+chr(49)+chr(48+num-10)).style.display="none" then
document.all("subtree"+chr(49)+chr(48+num-10)).style.display=""
document.all("image"+chr(49)+chr(48+num-10)).src="image/t_sub.gif"
document.all("img"+chr(49)+chr(48+num-10)).src="image/open.gif"
else
document.all("subtree"+chr(49)+chr(48+num-10)).style.display="none"
document.all("image"+chr(49)+chr(48+num-10)).src="image/t_plus.gif"
document.all("img"+chr(49)+chr(48+num-10)).src="image/close(1).gif"
end if
end if
end function
</script>

87,954

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧