<script>
function checkword(tobj,dobj){
var val=document.getElementById('txtre').innerText;
var txtuser2=document.getElementById('txtuser2').value;
var wor=tobj.value;
txtuser2=txtuser2+wor;
wor=wor.replace(/(^\s*)|(\s*$)/g,"");
var newval="";
var newval2="";
for(var ii=0;ii<val.length;ii++){
var oneword=val.substring(ii,ii+1);
if(ii<wor.length){
if(oneword==wor.substring(ii,ii+1)){
newval+="<font color='green'>"+wor.substring(ii,ii+1)+"</font>";
newval2+="<font color='#cccccc'>"+wor.substring(ii,ii+1)+"</font>";
}else{
newval+="<font color='red'>"+wor.substring(ii,ii+1)+"</font>";
newval2 += "<font color='red'>"+oneword+"</font>";
}
}
}
dobj.innerHTML=newval;
var newval2 = newval2+val.substr(wor.length,val.length);
document.getElementById('txtre').innerHTML=newval2;
document.getElementById('right').innerHTML = '正确个数:'+(newval.split('green').length-1);
document.getElementById('err').innerHTML = '错误个数:'+(newval.split('red').length-1);
}
document.onkeydown=function(){
if(event.keyCode==8){
var txtuser2 = document.getElementById('txtuser2').value;
document.getElementById('txtuser2').value = txtuser2.substr(0,txtuser2.length-1);
}
}
</script><style type="text/css">
#txtre,#txtsr,#txtuser{
font-size:25px;
}
#txtre{
width:500px
}
#txtsr{
width:500px
/*display:none;*/
}
#txtuser{
width:540px;
border-top-style: none;
border-right-style: none;
border-left-style: none;
border-bottom-style: dotted;
border-bottom-width: 1px;
border-bottom-color: #666666;
background:#f9f9f9;
}
font{
text-decoration: underline;
}</style>
<div id="right">正确个数:</div>
<div id="err">错误个数:</div>
<div id="txtre" style="height: 20px">Some English text. This program can test your input skills. Author: 青剑</div>
<div id="txtsr" style="height: 20px"> </div>
<input id="txtuser2" type="hidden" /> <input id="txtuser" onKeyUp="txtuser2.value=txtuser2.value+this.value;this.value='';checkword(txtuser2,document.getElementById('txtsr'))" type="text" /> <!--<textarea name="txtuser" cols="" rows="5" wrap="physical" id="txtuser" onKeyUp="checkword(this,document.getElementById('txtsr'))"></textarea>-->

lxq73061
- 粉丝: 37
- 资源: 28
最新资源
- [AB PLC例程源码][MMS_043640]DeviceNet Diagnostic.zip
- [AB PLC例程源码][MMS_039840]ASCII_Messaging.zip
- [AB PLC例程源码][MMS_040306]Configuration of AMCI 3601 Single Axis Stepper Motor Controller with.zip
- [AB PLC例程源码][MMS_040307]MD60, MD65 Drives control with CompactLogix.zip
- [AB PLC例程源码][MMS_040305]ASCII Read , Write for CompactLogix & Bul90.zip
- [AB PLC例程源码][MMS_040316]DINT Conversion of INT data type and Arithmatic comparison .zip
- [AB PLC例程源码][MMS_040315]Double INC and Double DEC of INT datatype.zip
- [AB PLC例程源码][MMS_040317]DINT Conversion of INT data type and Arithmetic operations like Div, Mul.zip
- [AB PLC例程源码][MMS_040319]Swaps Byte in an array.zip
- [AB PLC例程源码][MMS_040318]DINT data type to String data type conversion.zip
- [AB PLC例程源码][MMS_040322]Decoding of Boolean array.zip
- [AB PLC例程源码][MMS_040323]Encoding of Boolean array.zip
- [AB PLC例程源码][MMS_040324]Value search in an array.zip
- [AB PLC例程源码][MMS_040325]Bubble sorting.zip
- [AB PLC例程源码][MMS_040326]Level control using FBD.zip
- [AB PLC例程源码][MMS_040327]Ramp Control of Electrical parameters.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



评论1