The most famous example is the assignment of attribute values to new generals in Romance of the Three Kingdoms and Taige.
I have used javascript to create such a function, and by the way, hide the underline of the links in the page.
Everyone has a look Look, if you have any better optimization suggestions, feel free to mention them.
The following is the code:
The first is test.html:
Also link.css:
.A {
text-transform: none;
text-decoration: none;
}
.a:hover {
text -decoration: underline
}
Finally util.js (this code is quite long):
var flag=false;
function add(formname){
if (formname.username.value == "") {
alert("Please enter a positive integer");
formname.username.focus();
return false;
}
flag = checkscope(formname);
if(flag==false){
return false;
}
if( parseInt(formname.username.value)>0){
formname.username.value =parseInt(formname.username.value) 1;
if(parseInt(formname.username. value) parseInt(formname.meili.value)>10){
alert("The sum of the entered integers must not be greater than 10");
formname.username.value =10-parseInt(formname.meili.value );
return false;
}else
return true;
}else{
alert("The entered integer must be greater than 0");
formname.username.value =1 ;
return false;
}
}
function subtration(formname){
if (formname.username.value == "") {
alert("Please enter a positive integer");
formname.username.focus();
return false;
}
flag = checkscope(formname);
if(flag==false){
return false;
}
if( parseInt(formname.username.value)>1){
formname.username.value =parseInt(formname.username.value)-1;
if(parseInt (formname.username.value) parseInt(formname.meili.value)>10){
alert("The sum of the entered integers must not be greater than 10");
formname.username.value =10-parseInt( formname.meili.value);
return false;
}else
return true;
}else if(parseInt(formname.username.value) ==1){
alert(" It is already the minimum value and cannot be reduced anymore");
return false;
}else{
alert("The entered integer must be greater than 1");
formname.username.value =1;
return false;
}
}
function add2(formname){
if (formname.meili.value == "") {
alert("Please enter a positive integer ");
formname.meili.focus();
return false;
}
flag = checkscope(formname);
if(flag==false){
return false ;
}
if( parseInt(formname.meili.value)>0){
formname.meili.value =parseInt(formname.meili.value) 1;
if(parseInt(formname .username.value) parseInt(formname.meili.value)>10){
alert("The sum of the entered integers must not be greater than 10");
formname.meili.value =10-parseInt(formname. username.value);
return false;
}else
return true;
}else{
alert("The entered integer must be greater than 0");
formname.meili. value=1;
return false;
}
}
function subtration2(formname){
if (formname.meili.value == "") {
alert("Please Enter a positive integer");
formname.meili.focus();
return false;
}
flag = checkscope(formname);
if(flag==false){
return false;
}
if( parseInt(formname.meili.value)>1){
formname.meili.value =parseInt(formname.meili.value)-1;
if(parseInt(formname.username.value) parseInt(formname.meili.value)>10){
alert("The sum of the entered integers must not be greater than 10");
formname.meili.value =10 -parseInt(formname.username.value);
return false;
}else
return true;
}else if(parseInt(formname.meili.value) ==1){
alert("It is already the minimum value and cannot be reduced anymore");
return false;
}else{
alert("The entered integer must be greater than 1");
formname.meili.value =1;
return false;
}
}
function checkscope(formname){
if((parseInt(formname.username.value)>9)||(parseInt(formname .username.value)<1)){
alert("username input number exceeds the allowed range 1-9");
formname.username.value=1;
formname.username.focus( );
return false;
}
if((parseInt(formname.meili.value)>9)||(parseInt(formname.meili.value)<1)){
alert("meili input number exceeds the allowed range 1-9");
formname.meili.value=1;
formname.meili.focus();
return false;
}
return true;
}
Put the three files in the same folder, and then try the effect. I am definitely not lying to you.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn