图片下拉选择器的制作
//listID是对象的自定义属性,即在对象的标签中定义了这个属性值,现在就可以读取或改变。
myform.myhead.value=imgSrc.replace("数字序号",obj.listID);
document.images["imgselected"].src=imgSrc.replace("数字序号",obj.listID);
}
}
/* 以下控制下拉列表框的自动滚动 */
var mytime=setTimeout("",0);
var pre_X=0; //这个变量用来记录滚动前滚动条的位置
function scrollud(){ //本函数在下拉列表框滚动时被激活
var current_X=imgBox.scrollTop; //记录函数激活时滚动条的位置
//判断向上还是向下滚动,并自动滚动到"imgHeight"的整数倍。
//我们改变列表框的scrollTop值时,会自动激发其onscroll事件,循环激活本函数。
if(current_X>pre_X && imgBox.scrollTop< Math.ceil(imgBox.scrollTop/imgHeight)*imgHeight){
clearTimeout(mytime);
mytime=setTimeout("imgBox.scrollTop=Math.round(imgBox.scrollTop 1);",1);
}
else if(current_X<pre_X && imgBox.scrollTop> Math.floor(imgBox.scrollTop/imgHeight)*imgHeight){
clearTimeout(mytime);
mytime=setTimeout("imgBox.scrollTop=Math.round(imgBox.scrollTop-1);",1);
}
pre_X=current_X;
}
//使列表框自动滚动到默认选定的图片位置,并给"myhead"输入框以默认值
function init(){ //本函数在每个列表框中的图片加载时激活
imgBox.scrollTop=selectedNo*imgHeight; 内容来自dedecms
myform.myhead.value=imgSrc.replace("数字序号",selectedNo);
}
/* 以下使窗体点击时selectme(obj)函数被激活: */
myActivation="selectme(null)";
if(document.body.onclick)
{
eval(document.body.onclick.toString().replace('anonymous()','bodyclick()'));
document.body.onclick=new Function("bodyclick();" myActivation);
}
else document.body.onclick=new Function(myActivation);
-->
</script>
本文来自织梦
程序最后“使窗体点击时selectme(obj)函数被激活”部分可以用document.body.onclick=new Function("selectme(null)")简单替换之。但为了不和其它程序的窗体点击事件冲突,我们用了这段代码。详见拙作《完美解决一个事件激活多个函数》。你也可以将"myhead" 的type值设为"hide",这里为了演示,就将它显示了出来。

文章评论
共有位Admini5网友发表了评论 查看完整内容