--------------Msg.js------------------
/*
---By:秦迷
---Date:2009-03-12
*/
$=function(o){return typeof(o)=="string"?document.getElementById(o):o};
String.prototype.Trim = function(){return this.replace(/(^/s*)|(/s*$)/ig,"");}
function Add(str){
switch(str){
case "P":
var PText=$("TextBox1").value.Trim();
var flag=true;
for(var i=0;i<$("ListBox1").length;i++){
if(PText==$("ListBox1").options[i].text){
flag=false;
}
}
if (PText==""){
alert("请输入省的名称!");
return false;
}
else if(!flag){
alert("此省已输入,请另外选择!");
return false;
}
break;
case "C":
var CText=$("TextBox2").value.Trim();
var flag=true;
for(var i=0;i<$("ListBox2").length;i++){
if(CText==$("ListBox2").options[i].text){
flag=false;
}
}
var i=$("ListBox1").selectedIndex;
if(i<0){
alert("请先选择省再添加市!");
return false;
}
else if(CText==""){
alert("请输入市的名称!");
return false;
}
else if(!flag){
alert("此市已输入,请另外选择!");
return false;
}
break;
}
}
function Edit(str){
switch(str){
case "P":
var PText=$("TextBox1").value.Trim();
var flag=true;
for(var i=0;i<$("ListBox1").length;i++){
if(PText==$("ListBox1").options[i].text){
flag=false;
}
}
if($("ListBox1").selectedIndex<0){
alert("请选择需要编辑的省!");
return false;
}
else if (PText==""){
alert("省的名称不能为空!");
return false;
}
else if(!flag){
alert("此省已存在,不能编辑!");
return false;
}
break;
case "C":
var CText=$("TextBox2").value.Trim();
var flag=true;
for(var i=0;i<$("ListBox2").length;i++){
if(CText==$("ListBox2").options[i].text){
flag=false;
}
}
if($("ListBox2").selectedIndex<0){
alert("请选择需要编辑的市!");
return false;
}
else if(CText==""){
alert("市的名称不能为空!");
return false;
}
else if(!flag){
alert("此市已存在,不能编辑!");
return false;
}
break;
}
}
function Del(str){
switch(str){
case "P":
if($("ListBox1").selectedIndex<0){
alert("请选择需要删除的省!");
return false;
}
else if($("ListBox2").length>0){
alert("请先删除市再删除省!");
return false;
}
break;
case "C":
if($("ListBox2").selectedIndex<0){
alert("请选择需要删除的市!");
return false;
}
break;
}
}
--------------mycss.css--------------
body {font-size:14px;}
.pcdiv{margin: 0 auto; width: 350px; padding: 4px; text-align: center; border: solid 1px #ccc;}
.lbox{ width:150px; height:300px;}
.txt{ width:150px; border:solid 1px #ccc}
.btn{border:0; background:#0080C0; color:#FFFFFF;width:80px; height:25px;}
.boline{border-bottom: solid 1px #ccc;}
出处:http://www.rczjp.cn/HTML/090311/20093611093612.html