Railway number reading, railway number

Source: Internet
Author: User

Railway number reading, railway number

The previous article has introduced "test COM with IE", so we use an actual instance to use it.

Before that, we need to understand two Javascript Functions:

  • Replace (regexp/substr, replacement)

    Use this function to replace unnecessary spaces.

    str.replace(/\s/g, "");


  • Split (separator, howator)

Converts a string to a character array.

string.split(",");


I. js part

We put all the methods in a RepoInfo object.

var RepoInfo = { };

1. Get the object

RepoInfo.getObj = function(objName) {return new ActiveXObject(objName);};


2. Get the Array

RepoInfo.getArray = function(str) {var ret = new Array(16);var string = str.replace(/\s/g, "");ret = string.split(",");return ret;};



3. decoding string (1) input string verification. If the string is empty, exit. (2) Empty the output box before each assignment. (3) execute the methods in COM to get the object without being empty.

RepoInfo.decode = function(string) {if (string == null) return;var obj = RepoInfo.getObj("repoInfo.LabelInfo");var edtView = document.getElementById("edtView");edtView.value = " ";var str = RepoInfo.getArray(string);if (obj != null)edtView.value = obj.getInfo(str);};


Ii. html Section
1. Button events

Obtain the string from the input box as the input parameter of the js method. Note: Use the two quotation marks together.

<Input type = "button" id = "btnOk" value = "execute data parsing" onClick = "RepoInfo. decode (document. getElementById ('edtdata'). value)"/>


2. Page Effects

 

Tag data: 

Execution result: 




3. Source Code (including js Code)

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 


Post:

There are only two formal railway vehicle number development institutions (institutes/enterprises) in China: yuanwanggu and Wick.


Reference Document (W3School ):

1. replace Method

2. RegExp object

3. split Method

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.