易表在线答疑技术与交流用户社区 → [求助]向各位版主求教,一段js代码校验集装箱箱号是否正确的,想用易表的函数重构。


  共有12018人关注过本帖平板打印复制链接

主题:[求助]向各位版主求教,一段js代码校验集装箱箱号是否正确的,想用易表的函数重构。

帅哥哟,离线,有人找我吗?
jynet
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:39 积分:0 威望:0 精华:0 注册:2007/9/8 4:35:00
[求助]向各位版主求教,一段js代码校验集装箱箱号是否正确的,想用易表的函数重构。  发帖心情 Post By:2007/9/21 21:25:00 [只看该作者]

各位版主大家好,我在做一套系统的时候需要实现一个功能,就是校验集装箱箱号是否正确,在网上看了相关算法并找到了一段js代码,想用易表的函数重构,但是易表好像没有数组和子函数功能,苦思良久仍无进展,特来向各位版主求救,先行拜谢。
[code]// JavaScript Document
function changechar(str)
{
 
   if ((str=="a")||(str=="A"))
   return 10;
   else if ((str=="b")||(str=="B"))
   return 12;
       else if ((str=="c")||(str=="C"))
   return 13;
       else if ((str=="d")||(str=="D"))
   return 14;
       else if ((str=="e")||(str=="E"))
   return 15;
       else if ((str=="f")||(str=="F"))
   return 16;
       else if ((str=="g")||(str=="G"))
   return 17;
       else if ((str=="h")||(str=="H"))
   return 18;
       else if ((str=="i")||(str=="I"))
   return 19;
       else if ((str=="j")||(str=="J"))
   return 20;
       else if ((str=="k")||(str=="K"))
   return 21;
       else if ((str=="l")||(str=="L"))
   return 23;
       else if ((str=="m")||(str=="M"))
   return 24;
       else if ((str=="n")||(str=="N"))
   return 25;
       else if ((str=="o")||(str=="O"))
   return 26;
       else if ((str=="p")||(str=="P"))
   return 27;
       else if ((str=="q")||(str=="Q"))
   return 28;
       else if ((str=="r")||(str=="R"))
   return 29;
       else if ((str=="s")||(str=="S"))
   return 30;
       else if ((str=="t")||(str=="T"))
   return 31;
       else if ((str=="u")||(str=="U"))
   return 32;
       else if ((str=="v")||(str=="V"))
   return 34;
       else if ((str=="w")||(str=="W"))
   return 35;
       else if ((str=="x")||(str=="X"))
   return 36;
       else if ((str=="y")||(str=="Y"))
   return 37;
       else if ((str=="z")||(str=="Z"))
   return 38;
       else
   return -1000;
//if ((str=="a")||(str=="A"))
//return 10;
//else if (str=="b")
//return 1;
//else
//return 7;
}
function GetCntr(strcntr)
{
   var num = new Array(10)
   for (i=0;i<11;i++)
   {
       num[i]=0;
   }
   test=strcntr;//prompt("请输入需校验的集装箱编码","◎◎◎◎×××××××")
   len=test.length;
   if (len != 11)
   {
       alert("请重新输入11位的集装箱编码!");
       return false;
   //location.reload();
   }
   else

 回到顶部
总数 29 1 2 3 下一页