头大了,JS居然连函数也找不到,大家帮帮忙

JavaScript06

头大了,JS居然连函数也找不到,大家帮帮忙,第1张

</head>

<script language="javascript">

function readbigclass()

{

var selectobj=document.form1.selectbig

selectobj.length=0

for(i=0i<classary.lengthi++)

{

if(classary[i][3]==0){ selectobj.options[selectobj.length]=new Option(classary[i][1],classary[i][0])}

}

}

//加载小类列表

function readsmallclass()

{

var selectobj=document.form1.selectsmall

var bigclassid=document.form1.selectbig.options[document.form1.selectbig.selectedIndex].value

selectobj.length=0

for(i=0i<classary.lengthi++)

{

if(classary[i][2]==bigclassid)

{

selectobj.options[selectobj.length]=new Option(classary[i][1],classary[i][0])

}

}

}

function setvalue(obj,cvalue)

{

if(cvalue=="" || cvalue==null){return}

var m,n

m=obj.length

for(n=0n<mn++)

{

if(obj.options[n].value==cvalue)

{

obj.selectedIndex=n

return

}

}

}

function changcls()

{

var smallcls='<%=rs("classid")%>'

var bigcls

for(i=0i<classary.lengthi++)

{

if(classary[i][0]==smallcls)

{

setvalue(document.form1.selectbig,classary[i][2])

setvalue(document.form1.selectsmall,smallcls)

return

}

}

}

function delpicture()

{

var ischeck=document.form1.delpic.value

var obj=document.all("piclink")

alert(ischeck)

return

if(ischeck==true)

{

obj.style.text-decoration.value="line-through"

}

else

{

document.form1.piclink.style.text-decoration.value="none"

}

}

function testobj(){alert('测试')}

</script>

首先:

function getAttr(var id, var attr, var method)

{

......

}

函数声明不正确,(JS是弱类型语言,不可以加上var),应该修改为:

function getAttr(id, attr, method)

{

......

}

其他的就和楼上说的一样, 应该是document.getElementsByName返回的是个数组,需要写成:

case 1:

return document.getElementsByName(id)[0].getAttribute(attr)

......

return document.getElementsByTagName(id)[0].getAttribute(attr)