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



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.