JavaScript classic function

zhaozj2021-02-17  49

I gather the client to develop classic JavaScript methods, I hope you have added!

1. String alternative 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) (Expression.Substring (INDEX FINDLEN));

Return string_replaceb (newExp, find, replacewith, index 1 findlen);

2. Take a string length method function string_getlength (str) {var i, rt = 0; for (i = 0; i 256) RT ;} return Rt;}

3. Floating point method Function getFloat (NUM) {var Num = parsefloat (NUM); if (isnan (NUM)) NUM = 0; Return Num;}

4. Seeking a plural method (used to floating point number) Function GetInt (NUM) {Return Parseint (Getfloat (NUM));

5. Judging whether the text domain object is only 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 VAR LLIST = FMOBJ.AssignedUser; // The item VAR rlist = fmobj.waITEDUser; // On the right side Unselected item / / Double-click the item in the right SELECT Function AssignUser ) {If (rlist.selectedindex <0 || rlist.selected "RList.Options.Length) Return; Var i;

Llist.Options.LENGTH ; llist.Options [llist.Options.Length-1] .value = rlist.Options [rlist.selectedIndIndex] .value; llist.Options [llist.Options.Length-1] .text = rlist.Options [rlist.selectedindex] .TEXT;

For (i = rlist.selectedindex; 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 = 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 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.selected "; i = 0; i -) {i (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 = l List.selectedIndIndex; j = 0; i - ) {Rlist.Options.Length ; rlist.Options [rlist.Options.Length-1] .value = llist.Options [i] .value; rlist.Options [rlist.Options.L1NGTH-1] .text = llist.options [i] .Text; for (j = i; j

转载请注明原文地址:https://www.9cbs.com/read-29342.html

New Post(0)