【www.gdgbn.com--网页配色】





网页特效 动态改变select值
<script language="javascript">
var getselectvalue = funtion(select)
{   
    var idx = select.selectedindex,   
        option,   
        value;   
    if (idx > -1) {   
        option = select.options[idx];   
        value = option.attributes.value;   
        return (value && value.specified) ? option.value : option.text);    
   }   
    return null;   
}  
</script>


<script type="text/javascript">
var getselectvalue = function(select) {
var idx = select.selectedindex,
option,
value;
if (idx > -1) {
option = select.options[idx];
value = option.attributes.value;
return (value && value.specified) ? option.value : option.text;
}
return null;
}
</script>


其它关于网页特效 select内容,
1.判断select选项中 是否存在value="paravalue"的item
function 网页特效selectisexititem(objselect, objitemvalue) {
var isexit = false;
for (var i = 0; i < objselect.options.length; i++) {
if (objselect.options[i].value == objitemvalue) {
isexit = true;
break;
}
}
return isexit;
}

// 2.向select选项中 加入一个item
function jsadditemtoselect(objselect, objitemtext, objitemvalue) {
//判断是否存在
if (jsselectisexititem(objselect, objitemvalue)) {
alert("该item的value值已经存在");
} else {
var varitem = new option(objitemtext, objitemvalue);
objselect.options.add(varitem);
alert("成功加入");
}
}

// 3.从select选项中 删除一个item
function jsremoveitemfromselect(objselect, objitemvalue) {
//判断是否存在
if (jsselectisexititem(objselect, objitemvalue)) {
for (var i = 0; i < objselect.options.length; i++) {
if (objselect.options[i].value == objitemvalue) {
objselect.options.remove(i);
break;
}
}
alert("成功删除");
} else {
alert("该select中 不存在该项");
}
}


// 4.删除select中选中的项
function jsremoveselecteditemfromselect(objselect) {
var length = objselect.options.length - 1;
for(var i = length; i >= 0; i--){
if(objselect[i].selected == true){
objselect.options[i] = null;
}
}
}

本文来源:http://www.gdgbn.com/wangyezhizuo/25561/