I collect the client to develop the classic JavaScript method. I hope you can add it!
1. String replacement method.
Function string_replace (srcstring, findstring, replacestring ){
Return string_replaceb (srcstring, findstring, replacestring, 0 );
}
Function string_replaceb (expression, find, replacewith, start ){
VaR Index = expression. indexof (find, start );
If (Index =-1)
Return expression;
VaR findlen = find. length;
VaR newexp = "";
Newexp = expression. substring (0, index) + (replacewith) + (expression. substring (index + findlen ));
Return string_replaceb (newexp, find, replacewith, index + 1 + findlen );
}
2. String Length Method
Function string_getlength (STR ){
VaR I, rT = 0;
For (I = 0; I <Str. length; I ++)
{
RT ++;
If (Str. charcodeat (I)> 256) rt ++;
}
Return RT;
}
3. Floating Point Number Method
Function getfloat (Num)
{
VaR num = parsefloat (Num );
If (isnan (Num) num = 0;
Return num;
}
4. Integer method (using the floating point number method)
Function getint (Num)
{
Return parseint (getfloat (Num ));
}
5. Determines whether the text domain object is empty.
Function at_checkblank (OBJ, caption ){
If (string_replace (obj. value, "", "") = "")
{
OBJ. Select ();
Alert (Caption + "cannot be empty ¡");
OBJ. Focus ();
Return false;
}
Return true;
}
6. Two select objects (lList, rlist) operate on each other
VaR lList = fmobj. assigneduser; // The project is selected on the left.
VaR rlist = fmobj. waiteduser; // unselected project on the right
// Double-click the project in select on the right
Function assignuser (){
If (rlist. selectedindex <0 | rlist. selectedindex> rlist. Options. Length) return;
VaR I;
LList. Options. Length ++;
LList. Options [lList. Options. Length-1]. value = rlist. Options [rlist. selectedindex]. value;
LList. Options [lList. Options. Length-1]. Text = rlist. Options [rlist. selectedindex]. text;
For (I = rlist. selectedindex; I <rlist. Options. Length-1; I ++ ){
Rlist. Options [I]. value = rlist. Options [I + 1]. value;
Rlist. Options [I]. Text = rlist. Options [I + 1]. text;
}
Rlist. Length --;
}
// Add the selected on the right to the left
Function assignright_assignselected (){
For (VAR I = rlist. Length-1; I> = 0; I --){
If (rlist. Options [I]. Selected ){
LList. Options. Length ++;
LList. Options [lList. Options. Length-1]. value = rlist. Options [I]. value;
LList. Options [lList. Options. Length-1]. Text = rlist. Options [I]. text;
For (var j = I; j <rlist. Options. Length-1; j ++ ){
Rlist. Options [J]. value = rlist. Options [J + 1]. value;
Rlist. Options [J]. Text = rlist. Options [J + 1]. text;
}
Rlist. Length --;
}
}
}
// Add all on the right to the left
Function assignright_assignall (){
For (VAR I = rlist. Length-1; I> = 0; I --){
LList. Options. Length ++;
LList. Options [lList. Options. Length-1]. value = rlist. Options [I]. value;
LList. Options [lList. Options. Length-1]. Text = rlist. Options [I]. text;
For (var j = I; j <rlist. Options. Length-1; j ++ ){
Rlist. Options [J]. value = rlist. Options [J + 1]. value;
Rlist. Options [J]. Text = rlist. Options [J + 1]. text;
}
Rlist. Length --;
}
}
// Double-click the select project on the left
Function denyuser (){
If (lList. selectedindex <0 | lList. selectedindex> lList. Options. Length) return;
VaR I;
Rlist. Options. Length ++;
Rlist. Options [rlist. Options. Length-1]. value = lList. Options [lList. selectedindex]. value;
Rlist. Options [rlist. Options. Length-1]. Text = lList. Options [lList. selectedindex]. text;
For (I = lList. selectedindex; I <lList. Options. Length-1; I ++ ){
LList. Options [I]. value = lList. Options [I + 1]. value;
LList. Options [I]. Text = lList. Options [I + 1]. text;
}
LList. Length --;
}
// Add the selected items on the left to the right
Function assignright_denyselected (){
For (VAR I = lList. Length-1; I> = 0; I --){
If (lList. Options [I]. Selected ){
Rlist. Options. Length ++;
Rlist. Options [rlist. Options. Length-1]. value = lList. Options [I]. value;
Rlist. Options [rlist. Options. Length-1]. Text = lList. Options [I]. text;
For (j = lList. selectedindex; j <lList. Options. Length-1; j ++ ){
LList. Options [J]. value = lList. Options [J + 1]. value;
LList. Options [J]. Text = lList. Options [J + 1]. text;
}
LList. Length --;
}
}
}
// Add all projects on the left to the right
Function assignright_denyall (){
For (VAR I = lList. Length-1; I> = 0; I --){
Rlist. Options. Length ++;
Rlist. Options [rlist. Options. Length-1]. value = lList. Options [I]. value;
Rlist. Options [rlist. Options. Length-1]. Text = lList. Options [I]. text;
For (j = I; j <lList. Options. Length-1; j ++ ){
LList. Options [J]. value = lList. Options [J + 1]. value;
LList. Options [J]. Text = lList. Options [J + 1]. text;
}
LList. Length --;
}
}