Sequence Code Generator written in Javascript

Source: Internet
Author: User

A netizen asked me for help today. He wants to fill it out in Excel

 

Pdaa20124527000001
Pdaa2012452721302
Pdaa20124527000003

This sequence cannot be intelligently filled in Excel.

 

This can be done by writing VBA code, but I am not familiar with VBA and I still wrote one using JavaScript.

 

<Form> <p> <font color = "blue" size = "+ 2"> sequence generator v0.0.0001 </font> </P> <p> fixed part: <input type = "text" id = "txtfixed" value = "pdaa20124527"/> </P> <p> start value: <input type = "text" id = "txtbegin" value = "1"> end value: <input type = "text" id = "txtend" value = "999999"> step size: <input type = "text" id = "txtstep" value = "1"> <input type = "button" value = "generate sequence" onclick = "gencode (); "> </P> </form> <script language =" JavaScript "> function gencode () {sfixed = (Document. getelementbyid ("txtfixed"). value; If (0 = sfixed. Length) {If (! Confirm ("no fixed part indicated! \ N: Do you want to continue generating? ") {Return ;}} istart = (document. getelementbyid ("txtbegin ")). value; If (0 = istart. length) {alert ("start value not indicated! "); Return;} istart = istart/1; iend = (document. getelementbyid ("txtend ")). value; If (0 = iend. length) {alert ("no end value is specified! "); Return;} iend = iend/1; istep = (document. getelementbyid (" txtstep "). value; If (0 = istep. Length) {If (! Confirm ("no end value is specified! \ N must be 1 by default. Will the generation continue? ") {Return ;}} istep = istep/1; genserialcode ();} function genserialcode () {document. write ('<form name = "frmtest">'); document. write ('<textarea rows = "30" Cols = "90" name = "tatest">'); for (I = istart; I <iend + 1; I + = istep) {document. write (sfixed); var J = I; while (j = J * 10) <iend) {// document. writeln ("J =" + J); document. write ("0");} document. writeln (I);} document. write ('<\/textarea> <\/form>'); var tempval = eval ("document. frmtest. tatest "commandid tempval.focus(%%%%%tempval.select(%%%therange%tempval.createtextrange(%%%therange.exe ccommand (" copy ") ;}</SCRIPT>

 

Improved:

<Form> <p> <font color = "blue" size = "+ 2"> sequence generator v0.0.0001 </font> </P> <p> fixed part: <input type = "text" id = "txtfixed" value = "pdaa20124527"/> </P> <p> start value: <input type = "text" id = "txtbegin" value = "1"> end value: <input type = "text" id = "txtend" value = "999999"> step size: <input type = "text" id = "txtstep" value = "1"> <input type = "button" value = "generate sequence" onclick = "gencode (); "> </P> </form> <script language =" JavaScript "> function gencode () {sfixed = (Document. getelementbyid ("txtfixed"). value; If (0 = sfixed. Length) {If (! Confirm ("no fixed part indicated! \ N: Do you want to continue generating? ") {Return ;}} istart = (document. getelementbyid ("txtbegin ")). value; If (0 = istart. length) {alert ("start value not indicated! "); Return;} istart = istart/1; iend = (document. getelementbyid ("txtend ")). value; If (0 = iend. length) {alert ("no end value is specified! "); Return;} iend = iend/1; istep = (document. getelementbyid (" txtstep "). value; If (0 = istep. Length) {If (! Confirm ("no end value is specified! \ N must be 1 by default. Will the generation continue? ") {Return ;}} istep = istep/1; genserialcode ();} function genserialcode () {document. write ('<form name = "frmtest">'); document. write ('<textarea rows = "30" Cols = "90" name = "tatest">'); var J, imaxlen = string (iend ). length; for (I = istart; I <iend + 1; I + = istep) {document. write (sfixed); var ilen = imaxlen-string (I ). length; For (j = 0; j <ilen; j ++) {// document. writeln ("J =" + J); document. write ("0");} document. writeln (I);} document. write ('<\/textarea> <\/form>'); var tempval = eval ("document. frmtest. tatest "commandid tempval.focus(%%%%%tempval.select(%%%therange%tempval.createtextrange(%%%therange.exe ccommand (" copy ") ;}</SCRIPT>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.