
//角色添加
function add()


{
var sendcount,flag,delcount,num1;
flag=0;
delcount=0;
sendcount=document.send.s1.length;


for(i=0;i<sendcount;i++)
{
flag2=0;

if(document.send.s1[i].selected==true)
{
num1=document.send.sendnum.length
optnumadd=document.createElement("option");
optnumadd.text=document.send.s1[i].text;

optnumadd.value=document.send.s1[i].value;
document.send.sendnum.add(optnumadd);
delcount=delcount+1;
for(k=0;k<document.send.q2.length;k++)

{
if(document.send.q2[k].value==document.send.s1[i].value)

{document.send.q2.remove(k);
flag2=1;
}
}
if(flag2==0)

{
optnumadd=document.createElement("option");
optnumadd.text=document.send.s1[i].text;
optnumadd.value=document.send.s1[i].value;
optnumadd.selected=true;
document.send.q1.add(optnumadd);
}

}
}
delcount=0;

for(i=0;i<sendcount;i++)
{

if(document.send.s1[i].selected==true)
{
flag=1;

for(j=i;j>0;j--)
{
document.send.s1[j].value=document.send.s1[j-1].value;
document.send.s1[j].text=document.send.s1[j-1].text;
}
delcount=delcount+1;
}
}

if (flag==0)
{
alert("請(qǐng)?jiān)谖窗僮鞯牧斜碇羞x擇要添加的操作!");
}

for(i=0;i<delcount;i++)
{
document.send.s1.remove(0);
}

for(i=0;i<document.send.s1.length;i++)
{
document.send.s1[i].selected=false;
}



}

//角色刪除
function del()


{
var sendcount,flag,delcount;
flag=0;
delcount=0;
sendcount=document.send.sendnum.length;


for(i=0;i<sendcount;i++)
{
flag2=0;

if(document.send.sendnum[i].selected==true)
{
num1=document.send.s1.length
optnumadd=document.createElement("option");
optnumadd.text=document.send.sendnum[i].text;
optnumadd.value=document.send.sendnum[i].value;
document.send.s1.add(optnumadd);

for(k=0;k<document.send.q1.length;k++)

{
if(document.send.q1[k].value==document.send.sendnum[i].value)

{document.send.q1.remove(k);
flag2=1;
}
}
if(flag2==0)

{
optnumadd=document.createElement("option");
optnumadd.text=document.send.sendnum[i].text;
optnumadd.value=document.send.sendnum[i].value;
optnumadd.selected=true;
document.send.q2.add(optnumadd);
}
}
}



for(i=0;i<sendcount;i++)
{

if(document.send.sendnum[i].selected==true)
{
flag=1;

for(j=i;j>0;j--)
{
document.send.sendnum[j].value=document.send.sendnum[j-1].value;
document.send.sendnum[j].text=document.send.sendnum[j-1].text;
}
delcount=delcount+1;
}
}

if (flag==0)
{
alert("請(qǐng)?jiān)谝寻慕巧斜碇羞x擇要?jiǎng)h除的角色!");
}

for(i=0;i<delcount;i++)
{
document.send.sendnum.remove(0);
}

for(i=0;i<document.send.sendnum.length;i++)
{
document.send.sendnum[i].selected=false;
}
}



//搜索需要添加的角色

function search_s1()


{

if(document.send.textfield1.value=="")

{alert("請(qǐng)先輸入搜索的角色名!");
return true;
}
num2=document.send.s1.length;
qqq=0;
for(i=0;i<num2;i++)

{stringX1=document.send.s1[i].text;
stringX2=document.send.textfield1.value;
numberx=stringX1.indexOf(stringX2)

if(numberx!=-1)
{
document.send.s1[i].selected=true;
qqq=1;
}
else

{
document.send.s1[i].selected=false;
}
}
if(qqq==0)

{alert("抱歉!您搜索的角色不存在!!");}


}


function search_sendnum()
{
if(document.send.textfield2.value=="")

{alert("請(qǐng)先輸入搜索的角色名!");
return true;
}
num1=document.send.sendnum.length;
qqq=0;

for(i=0;i<num1;i++)

{stringX1=document.send.sendnum[i].text;
stringX2=document.send.textfield2.value;
numberx=stringX1.indexOf(stringX2)

if(numberx!=-1)
{
document.send.sendnum[i].selected=true;
qqq=1;
}
else

{
document.send.sendnum[i].selected=false;
}

}
if(qqq==0)

{alert("抱歉!您搜索的角色不存在!!");}


}

//校驗(yàn)是否為英文
function checkchar()


{
var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for (i=0; i < document.form.aaa.value.length; i++)

{
var CheckChar = document.form.aaa.value.charAt(i);
CheckChar = CheckChar.toUpperCase();
if (Letters.indexOf(CheckChar) == -1)

{
alert ("輸入類型必須為英文!");
return false;
}
}
}

//校驗(yàn)是否為數(shù)字

function checknum(p)


{
if (p == "")


{alert ("輸入不能為空!");
return false;
}
var l = p.length;
var count=0;
for(var i=0; i<l; i++)


{
var digit = p.charAt(i);
if(digit == "." )


{
++count;
if(count>1)

{alert ("輸入類型必須為數(shù)字!");
return false;
}
}
else if(digit < "0" || digit > "9")

{alert ("輸入類型必須為數(shù)字!");
return false;
}
}
return true;
}

//校驗(yàn)IP地址格式
function checkip()


{
var scount=0;
var ip = document.form3.ccc.value;
var iplength = ip.length;
var Letters = "1234567890.";
for (i=0; i < document.form3.ccc.value.length; i++)

{
var CheckChar = document.form3.ccc.value.charAt(i);
if (Letters.indexOf(CheckChar) == -1)

{
alert ("IP地址格式不對(duì)!!,只能輸入數(shù)字和“.”,格式為XXX.XXX.XXX.XXX 例如:192.168.0.1");
document.form3.ccc.value="";
document.form3.ccc.focus();
return false;
}
}

for (var i = 0;i<iplength;i++)
(ip.substr(i,1)==".")?scount++:scount;
if(scount!=3)


{
alert ("IP地址格式不對(duì)!,只能輸入數(shù)字和“.”,格式為XXX.XXX.XXX.XXX 例如:192.168.0.1");
document.form3.ccc.value="";
document.form3.ccc.focus();
return false;
}

first = ip.indexOf(".");
last = ip.lastIndexOf(".");
str1 = ip.substring(0,first);
subip = ip.substring(0,last);
sublength = subip.length;
second = subip.lastIndexOf(".");
str2 = subip.substring(first+1,second);
str3 = subip.substring(second+1,sublength);
str4 = ip.substring(last+1,iplength);

if (str1=="" || str2=="" ||str3== "" ||str4 == "")


{alert("數(shù)字不能為空!格式為XXX.XXX.XXX.XXX 例如:192.168.0.1");
document.form3.ccc.value="";
document.form3.ccc.focus();
return false;
}
if (str1< 0 || str1 >255)


{alert ("數(shù)字范圍為0~255!");
document.form3.ccc.value="";
document.form3.ccc.focus();
return false;
}
else if (str2< 0 || str2 >255)


{alert ("數(shù)字范圍為0~255!");
document.form3.ccc.value="";
document.form3.ccc.focus();
return false;
}
else if (str3< 0 || str3 >255)


{alert ("數(shù)字范圍為0~255!");
document.form3.ccc.value="";
document.form3.ccc.focus();
return false;
}
else if (str4< 0 || str4 >255)


{alert ("數(shù)字范圍為0~255!");
document.form3.ccc.value="";
document.form3.ccc.focus();
return false;
}

//校驗(yàn)電話號(hào)碼
function checkphone()


{
var Letters = "1234567890,";
for (i=0; i < document.form4.ddd.value.length; i++)

{
var CheckChar = document.form4.ddd.value.charAt(i);
if (Letters.indexOf(CheckChar) == -1)

{
alert ("電話號(hào)碼只能為數(shù)字或逗號(hào)!");
return false;
}
}
}


}



posted on 2007-07-11 13:08
冰封的愛(ài) 閱讀(333)
評(píng)論(0) 編輯 收藏 所屬分類:
常用工具