万能表单处理程序

类别:Asp 点击:0 评论:0 推荐:

<script language="javascript">
//-----------------------------debug------------------------------
//var property_string="||" split by the char “||“///////////////////////////////
//powered BY AIRZEN
//qq:39192170
//e_mail:[email protected]
//website:www.windeye.com
//date:2004-8-21
//转贴请保留作者信息

function get_value(obj){
var this_star,this_end;
var return_value;
this_star=property_string.indexOf(obj.name+"=");
if(this_star==-1){//not found
return_value=null;
}else{
this_end=property_string.indexOf("||",this_star);
if(this_end==-1){
this_end=10000;
}
return_value=property_string.substring(this_star+obj.name.length+1,this_end);
}
return return_value;
}

function auto_OP(obj){
var this_type;
var this_value;
this_type=obj.type;
this_value=get_value(obj);
if(this_value==null){
//alert("not exist");
return false;
}
if(this_type=="text"){//input
obj.value=this_value;
}else if(this_type=="textarea"){//textarea
obj.value=this_value;
}else if(this_type=="select-one"){//select-one
for(var x=0;x<obj.length;x++){
if(obj[x].value==this_value){
obj[x].selected=true;
break;
}
}
}else if(this_type=="radio"){// radio
if(obj.value==this_value){obj.checked=true;}
}else if(this_type=="checkbox"){//checkbox
if(obj.value==this_value){obj.checked=true;}
}else if(this_type=="hidden"){
obj.value=this_value;
}
}


function doc_init(form){
for(var x=0;x<form.length;x++){
auto_OP(form1[x]);
//document.write(x+"   name: "+form[x].name+" value "+form1[x].value+"  type : "+form1[x].type+"<br>");
}
}

var property_string="<%=out_txt%>";
doc_init(form1);
</script>

本文地址:http://com.8s8s.com/it/it8663.htm