今天写的,项目要求的控制取值的代码,放上来让大家轻拍一下。 需求:图片可以多选,单独提取第一次选取图片的值、提取用户选择的所有图片的值并保存。 那位高手有更好的方法,请留下脚印,谢谢!^-^ <!-- .picqa{ cursor:hand; float:left; border:5px #333 solid; padding:1px; margin:2px; } .picqa_active{ cursor:hand; float:left; border:5px #FF0000 solid; padding:1px; margin:2px;} --> <!-- var ifactive = 0; function changpicclass(thisid,thisvalue){ //改变图片样式 if(document.getElementById(thisid).className == "picqa") { document.getElementById(thisid).className = "picqa_active"; ifactive = 1;} else { document.getElementById(thisid).className = "picqa"; ifactive = 0;} //写值 window.document.muchcombo_tt.firsiclick.value == "" ? window.document.muchcombo_tt.firsiclick.value = thisvalue : (window.document.muchcombo_tt.clickpicvalue.value = writeclickpicvalue(thisvalue)); //alert(window.document.muchcombo_tt.firsiclick.value); function writeclickpicvalue(thisvalue){ var s = window.document.muchcombo_tt.clickpicvalue.value; if(ifactive == 1){ s = s + thisvalue; s = s.replace(/\s/g,""); return s; }else{ s = s.replace(thisvalue,""); return s;} } //用户离开时间过长时候,清空文本框,放置缓存 setTimeout('clear()',10000); } function clear(){ window.document.muchcombo_tt.clickpicvalue.value = "";} --> pic1 pic2 pic3 pic4 firstClickValue: OtherClickValue: [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]