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));"
]