Function MarkSelectByID (a, B ){
Var m = document. getElementById ("tx_markname ");
Var num = 0;
If (num <= 3 & $ ("# lbl_MarkSelect" + B + "" ).css ("background-color") = "transparent") // no selection
{
If (m. value! = ""){
If (m. value. substr (m. value. length-1 )! = ""){
M. value + = "";
}
Var s = $ ("# tx_markname"). val (). split (""); // traverse the text box
If (s. length <4 ){
M. value + = a + "";
$ ("# Lbl_MarkSelect" + B + "" ).css ("background-color", "# f2eada ");
}
} Else {
M. value + = a + "";
$ ("# Lbl_MarkSelect" + B + "" ).css ("background-color", "# f2eada"); // set it to ivory after it is selected
}
Num + = 1;
}
// Select the selected tag and click "Remove style" again. The corresponding values in the text box are also removed.
Else {
// If no space is given at the end of the text box, a space is given by default.
If (m. value. substr (m. value. length-1 )! = ""){
M. value + = "";
}
$ ("# Lbl_MarkSelect" + B + "" ).css ("background-color", "transparent ");
M. value = m. value. replace (a + "","");
Num-= 1;
}
}
Var m; // The value when the three tags are saved to control the value exceeding the tag
// Method for changing the text box Value
Function MatkChange (){
Var g = $ ("# tx_markname"). val ();
// Clear the first space
If (g = ""){
$ ("# Tx_markname"). val ("");
}
// Two consecutive spaces are not allowed.
If (g. substr (g. length-) = "" & g. substr (g. length-) = ""){
$ ("# Tx_markname"). val (g. substr (0, g. length-1 ));
}
// Clear all styles
$ (". Cs_Mark"). each (function (){
Certificate (this).css ("background-color", "transparent ");
});
Var s = $ ("# tx_markname"). val (). split (""); // traverse the text box
Var num = s. length-1;
If (num = 3 ){
Var LastIndex = $ ("# tx_markname"). val (). lastIndexOf ("");
M = $ ("# tx_markname"). val (). substr (0, LastIndex + 1 );
$ ("# Tx_markname"). val (m );
}
If (num> 3 ){
$ ("# Tx_markname"). val (m );
}
Var j = $ ("# tx_markname"). val (). split ("");
$. Each (j, function (){
Var a = this; // each element in the text box
$ (". Cs_Mark"). each (function (){
If (a = this. text ){
Certificate (this).css ("background-color", "# f2eada ");
}
});
});
}