admin.js
上传用户:szhf331
上传日期:2022-06-22
资源大小:1032k
文件大小:5k
- var $=function(tagName){return document.getElementsByTagName(tagName);}
- var $div=function(tagName){
- return document.getElementById(tagName+"_txt");
- }
- var $val=function(tagName){
- return document.getElementById(tagName);
- }
- var $inp=function(tagName){
- return document.getElementsByName(tagName);
- }
- var $sel=function(tagName){
- return document.getElementById(tagName).options[document.getElementById(tagName).selectedIndex];
- }
- function CheckSel(Voption,Value)
- {
- var obj = document.getElementById(Voption);
- for (i=0;i<obj.length;i++){
- if (obj.options[i].value==Value){
- obj.options[i].selected=true;
- break;
- }
- }
- }
- function chkradio(Obj,Val)
- {
- if (Obj)
- {
- for (i=0;i<Obj.length;i++){
- if (Obj[i].value==Val){
- Obj[i].checked=true;
- break;
- }
- }
- }
- }
- function CheckAll(form)
- {
- for (var i=0;i<form.elements.length;i++)
- {
- var e = form.elements[i];
- if (e.Name != "chkAll")
- e.checked = form.chkAll.checked;
- }
- }
- function unselectall()
- {
- if(document.del.chkAll.checked){
- document.del.chkAll.checked = document.del.chkAll.checked&0;
- }
- }
- function ConfirmDel(formObj)
- {
- if(confirm("确定要删除选中的标题吗?一旦删除将不能恢复!")){
- eval(formObj).submit();
- return true;
- }else{
- return false;}
- }
- function power_chkll(id){
- var oEvent = document.all(id);
- var chks = oEvent.getElementsByTagName("INPUT");
- oEvent.power_id_ = !oEvent.power_id_;
- if (oEvent.power_id_){
- for (i=0;i<chks.length;i++){
- chks[i].checked=true;
- }
- } else{
- for (i=0;i<chks.length;i++){
- chks[i].checked=false;
- }
- }
- }
- function setSel(str,formname){
- for(var i=0;i<formname.options.length;i++){
- if (formname.options[i].text==str){
- formname.selectedIndex=i;
- break;
- }
- }
- }
- function setSel2(str,formname){
- for(var i=0;i<formname.options.length;i++){
-
- if (formname.options[i].value==str){
- formname.selectedIndex=i;
- break;
- }
- }
- }
- function fillSel(strsel,formname){
- formname.options.length=0;
- formname.options[0] = new Option(strsel,"0");
- formname.selectedIndex = 0;
- }
- function addOption(pos,formname){
- var strName = "请选择...";
- var strValue = "0";
- var objOption = new Option(strName,strValue);
- if (pos == -1 & pos > formname.options.length)
- formname.options[formname.options.length] = objOption;
- else
- formname.add(objOption, pos);
- }
- function postinfos(str_infos,str_urls,str_nowobj,str_nextobj){
- var xmlhttp;
- try{
- xmlhttp=new XMLHttpRequest();
- }
- catch(e){
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function(){
- if (xmlhttp.readyState==4){
- if (xmlhttp.status==200){
- var data=xmlhttp.responseText;
- results(data,str_nowobj,str_nextobj);
- }
- else{
- fillSel("传输失败!",$val(str_nextobj));
- $div(str_nextobj).innerHTML="<img src='images/reg_yesno.gif' alt='文件传输失败!'>";
- }
- }
- else{
- fillSel("正在刷新...",$val(str_nextobj));
- $div(str_nextobj).innerHTML="<img src='images/loading.gif' alt='正在刷新...'>";
- }
- }
- var url = str_urls + "?timeStamp=" + new Date().getTime();
- xmlhttp.open("post", url, true);
- xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=gb2312');
- xmlhttp.send(str_infos);
- }
- function results(data,str_nowobj,str_nextobj){
- var pronames
- var data_arr
- if(data!="0"){
- data = data.split('%%');
- $val(str_nextobj).options.length=0;
- $val(str_nextobj).options[0] = new Option("请选择...","0");
- for(data_i=0;data_i<data.length;data_i++){
- data_arr=data[data_i];
- data_arr=data_arr.split('||');
- $val(str_nextobj).options[data_i+1] = new Option(data_arr[1],data_arr[0]);
- }
- $val(str_nextobj).selectedIndex = data_i;
-
- //setSel(opt0[0],$val(str_nextobj))
- $div(str_nextobj).innerHTML="<img src='images/reg_yesok.gif' alt='列表更新成功!'>";
- if (typeof(checkdef)=="function"){
- checkdef(str_nextobj);
- }else{
- $val(str_nextobj).options[0].selected = true;
- }
- }else{
- fillSel("列表为空...",$val(str_nextobj));
- $div(str_nextobj).innerHTML="<img src='images/reg_yesno.gif' alt='列表为空,请添加相关类别!'>";
- }
- }
- function delRow(sIndex){
- $val("idTB").deleteRow(sIndex);
- $val("idFirst").innerText=idTB.rows.length-1;
- }
- function setRow(){
- var setrows=$val("idFirst").value;
- if (setrows>0&&setrows<101){
- var setrows=$val("idFirst").value*1+1;
- var nowrows=$val("idTB").rows.length*1;
- var rownum1=setrows-nowrows;
- var rownum2=nowrows-setrows;
- if (rownum1>0){
- for (i=0;i< setrows-nowrows;i++ ){
- addRow();
- }
- }else if (rownum2>0){
- for (i=0;i<rownum2;i++ ){
- delRow(nowrows-1-i);
- }
- }else if (rownum2==0){
- return false;
- }
- }else{
- alert('错误:行数设定限制为0-100行!');
- }
- window.location.href="#bottom";
- }