The implementation of JavaScript infinite classification algorithm

Source: Internet
Author: User
Tags array include key sql query split
javascript| algorithm through ASP dynamic generation of JS array, and then JS in the client to arrange, the largest reduction of server-side pressure. (Server-side only query once, no other action)

Database design:

ID: Index, AutoNumber
Mc:varchar 100 bytes, record category name
FL: number, records belong to which category, 0 is the root category
CEng: Number, records in the number of layers of the root classification of 0 layer, then increase by 1

The generated HTML code is as follows:



fenlei








The server-side ASP code is as follows:





fenlei








Explain:

ASP query database, generate JS data object (not array, similar)
Database of different rows, corresponding to different temparray[0] temparray[1] ...
Different fields are segmented by "@_!_#_$_|_@" in each piece of data to avoid duplication with the text in the data.

Using JS to rearrange temparray by recursion algorithm to get dataarray and to cycle Print to option in select



Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.