序列代码生成器

来源:互联网 发布:阿里算法工程师薪资 编辑:程序博客网 时间:2024/05/29 17:44
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>序列代码生成器</title>
<script language="javascript">
function generateCodes(firstpart,numwidth,numstart,numend,secondpart,thirdpart)
{
firstpartvalue 
= firstpart.value;
secondpartvalue 
= secondpart.value;
thirdpartvalue 
= thirdpart.value

iwidth 
= 0;

    
for( i = numstart.value ; i <= numend.value ; i++)
    {
            tail 
= "";
            iwidth 
= getsize(i);
            
for( j = 0 ; j < numwidth.value-iwidth ; j++) tail+="0";
            
            tail
+=i;
            document.write(firstpartvalue
+tail+secondpartvalue);
            
if(thirdpartvalue != "")document.write(tail+thirdpartvalue);
    }


}

function getsize( num )
{
if( num == 0 ) return 0;

size 
= 0;

while(  (num = Math.floor(num/10)) != 0   )size=size+1;

return size+1;

}


</script>

</head>
<body>
<form id="form1" name="form1" method="post" action="">
  
<label>第一部分:
  
<textarea name="firstpart" cols="100" rows="5" id="firstpart"></textarea>
  
<br />
  
<br />
  
</label>
  
<p>
    
<label>第二部分:
    
<textarea name="secondpart" cols="100" rows="5" id="secondpart"></textarea>
    
</label>
  
</p>
  
<p>第三部分:
    
<textarea name="thirdpart" cols="100" rows="5" id="thirdpart"></textarea>
  
</p>
  
<p>
    
<label>数值宽度:
    
<input name="numwidth" type="text" id="numwidth" size="10" />
    
</label>
</p>
  
<p>
    
<label>起始数值:
      
<input name="numstart" type="text" id="numstart" size="10" />
    
</label>
    
<label>结束数值:
      
<input name="numend" type="text" id="numend" size="10" />
    
</label>
  
</p>
  
<p>
    
<label>
    
<input type="button" name="button1" value="生成代码"  onclick="generateCodes(firstpart,numwidth,numstart,numend,secondpart,thirdpart)"/>
    
</label>
    
<label></label>
  
</p>
  
<p>
    
<label>功能:第一部分+数值序列+第二部分+数值序列+第三部分,试一下就知道了。</label>
  
<script>

  
</script>
  
</p>
</form>
</body>
</html>
 http://www.cnblogs.com/manio/archive/2006/06/28/437569.html