1. Problem background: When working on a project, I encountered a small business that displays the name of the customer department (Pinyin). There is a corresponding Pinyin under the department name, and in the existing database There is no corresponding field in , and the number of departments is relatively large. It is time-consuming to add. I wonder if it can be implemented in js and processed on the page.
2. Principle description The program principle is very simple. You can find the data dictionary of Chinese pinyin on the Internet. However, since everyone knows that the Chinese characters in the GB2312 encoding are sorted by pinyin, as long as you know that each pinyin is first The Chinese character codes can be used to calculate the pinyin codes of all Chinese characters.
This article customizes the data dictionary used to store the corresponding Chinese character pinyin and ascii code, then converts the Chinese characters that need to be converted into ascii code (two digits), and finally searches the dictionary for matching. See the code for specific implementation.
3. Implementation code:
Call code:
/*Transfer To uppercase*/
Onblur = "alert(myConvertToUpper(this.value));"
/*Convert to lowercase*/
Onblur = "alert(myConvertToLower (this.value));"
]
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn