打DOTA输了一晚了,郁闷啊,睡不着,就写了个,不知道对不对...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
var oData = {
"A" : "0235",
"B" : "4",
"C" : "78",
"D" : "169"
};
var strSource = strDest = ABC = "";String.prototype.order = function(){
return this.split("").sort().join("");
};
function $(id){
return document.getElementById(id);
}
window.onload = function(){
for(var pro in oData){
strSource += oData[pro];
}
$("sValue").innerHTML = ABC = strSource.order();;
var btn = $("btnContainer").getElementsByTagName("input");
for(var i=0; i<btn.length; i++){
btn[i].onclick = function(){
this.isClick = !this.isClick;
var val = oData[this.id];
if(this.isClick){
strSource = strSource.replace(val, "");
strDest += val;
}else{
strSource += val;
strDest = strDest.replace(val, "");
}
$("sValue").innerHTML = ABC = strSource.order();
$("dValue").innerHTML = strDest.order();
};
}
};
</script>
</head><body>
<form id="form1" name="form1" method="post" action="">
<table width="400" border="1" align="center" cellpadding="5">
<tr>
<td width="50%" id="btnContainer">
<input type="button" name="A" id="A" value=" A " />
<input type="button" name="B" id="B" value=" B " />
<input type="button" name="C" id="C" value=" C " />
<input type="button" name="D" id="D" value=" D " />
</td>
<td><div id="sValue"> </div></td>
</tr>
<tr>
<td> </td>
<td><div id="dValue"> </div></td>
</tr>
</table>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
var oData = {
"A" : "0235",
"B" : "4",
"C" : "78",
"D" : "169"
};
var strSource = strDest = ABC = "";String.prototype.order = function(){
return this.split("").sort().join("");
};
function $(id){
return document.getElementById(id);
}
window.onload = function(){
for(var pro in oData){
strSource += oData[pro];
}
$("sValue").innerHTML = ABC = strSource.order();;
var btn = $("btnContainer").getElementsByTagName("input");
for(var i=0; i<btn.length; i++){
btn[i].onclick = function(){
this.isClick = !this.isClick;
var val = oData[this.id];
if(this.isClick){
strSource = strSource.replace(val, "");
strDest += val;
}else{
strSource += val;
strDest = strDest.replace(val, "");
}
$("sValue").innerHTML = ABC = strSource.order();
$("dValue").innerHTML = strDest.order();
};
}
};
</script>
</head><body>
<form id="form1" name="form1" method="post" action="">
<table width="400" border="1" align="center" cellpadding="5">
<tr>
<td width="50%" id="btnContainer">
<input type="button" name="A" id="A" value=" A " />
<input type="button" name="B" id="B" value=" B " />
<input type="button" name="C" id="C" value=" C " />
<input type="button" name="D" id="D" value=" D " />
</td>
<td><div id="sValue"> </div></td>
</tr>
<tr>
<td> </td>
<td><div id="dValue"> </div></td>
</tr>
</table>
</form>
</body>
</html>
解决方案 »
- 使用jquery validate的时候无法触发 鼠标离开的时候进行验证?我设置了onfocusout为true.但是还是不行 。求教
- 一个树形菜单的问题。
- 大家看看仿IE选项卡的建立是怎么回事
- 求大哥大姐帮帮忙~~怎么将树(treetable)初始时只显示大节点。
- JS如何控制IFRAME里的控件?
- 帮忙看个JAVASCRIPT方法。
- 关于ActiveX控件的显示问题
- 请高手解决一下 下列的问题
- 為什麼 select 中 options 的子不能全部刪除,總是留一個???
- html js 数组 赋值太长的问题
- 求助一个初级的访问对象问题
- ●●●●●●●●●●●●这个方法好像没有用啊?????????
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
var oData = [ "0235", "4", "78", "169" ];
var ABC = "";function $(selector){
return document.getElementById(selector);
}
function $T(selector,context){
return (context||document).getElementsByTagName(selector);
}
function init(){
var allChar = '0123456789';
var divShow = $('divShow'),divOp = $('divOp');
var chks = $T('input',divOp),sps = $T('span',divOp),length = chks.length;
var txtSource = $("txtSource"),txtRemove = $("txtRemove"); txtSource.value = allChar; for(var i = 0; i<length; chks[i].value = sps[i].innerHTML = oData[i++])
chks[i].onclick = filterString; function filterString(){
var str = this.value,ABC =txtSource.value, strRemove = txtRemove.value;
var reg = new RegExp(str.split('').join('|'),'g');
if(this.checked){
ABC = ABC.replace(reg,'');
strRemove += str;
}else{
ABC += str;
strRemove = strRemove.replace(reg,'');
}
txtSource.value = ABC = ABC.split('').sort().join('');
txtRemove.value = strRemove.split('').sort().join('');
}
};
window.onload = init;
</script>
</head><body>
<div id="divShow"><input type="text" id="txtSource" size="12"><input type="text" id="txtRemove" size="12"></div>
<div id="divOp">
<input type="checkbox" id="" value=""><span></span>
<input type="checkbox" id="" value=""><span></span>
<input type="checkbox" id="" value=""><span></span>
<input type="checkbox" id="" value=""><span></span>
</div></body>
</html>
换个checkbox版的