ASP tree map generation program (source code) connected to the database

zhaozj2021-02-17  75

<% '*********************************************************************** **************************** Assummed that you have established SQL Server Database Unittree and in the library Established on the table: 'Units (ID unit number unique, NAME unit name string, UPID superior unit number)' Note: UPID = 0 indicates that the unit is an root node unit; 'Enter some data such as: (1, AA , 0) (2, AABB, 1) (3, AACC, 1) (4, AABB11, 2) 'to perform the following program test.

%> <% 'Establishing Database Connection SET CONN = Server.createObject ("AdoDb.Connection") Conn.open "provider = SQLOLEDB; DATA SOURCE = YoursrcName; user ID = sa; password =; database = unittree"%> <% 'Sub Process: Generated Tree Knight Node Data SUB TREENODE (CODE) SQLUnit = "SELECT ID, NAME" & _ "from Units" & _ "Where Upid =" & Code & "" & _ "Order By ID" set = conn.execute (SQLUNIT) Do While NOT RSUNIT.EOF Response.write ("Node" & RSUNIT ("ID") & "= appendchild (" & "Node" & Code & ", FolderNode ('" & ritit ("name") & "', ' "& RSUNIT (" ID ") &" ', 0) "& chr (10)) Call Treenode (RSUnit (" ID ")) rsunit.movenext loop end subs%> exercise / TITLE> <script language = "javascript"> / ********************************************************************* ************************************************ / Function GenerateTree () {// Spanning Tree Data / / ----- VBScript- ---- <% '' display unit SQLUNIT0 = "SELECT ID, NAME" & _ "from units" & _ "where upid = 0" & _ "Order by id" set rsunit0 = conn.execute (SQLUnit0 ) // root node Folderstree Response.write ("Folderstree = foldernode ('" & = "" & ") & rsunit0 (" ID ") &" ") &" ") &" ") &" ")") Response. Write ("Node" & RSUnit0 ("ID") & "= folderstree" & chr (10)) Call Treenode (RsUnit0 ("ID"</p> <p>)) // sub-node data%>} / ************************** Generated tree diagram end **** ************************** / </ script> <script language = "javascript"> / *********** ************** related functions *********************************/ / / Generate a node Function Foldernode (Name, Value, Flagopen) {var Arrayaux Arrayaux = New Array Arrayaux [0] = flagopen // Node Close 0 or Open 1 Arrayaux [1] = value // arrayaux [2] = name // Name return arrayaux}</p> <p>// Add its child function appendchild (parent [parent.length] = child return child = child return</p> <p>// Draw point // Parameter FoldersNode: Node // DOC: Document Object // Level: Non-point Level // Lastnode: The Last Node // Leftside: Picture Function RedRawnotes (FoldersNode, Doc, Level, LastNode, Leftside) {filename = "content.asp" // Set the hyperlink file, can be rewritten according to your situation .............</p> <p>VAR J = 0 VAR i = 0</p> <p>Doc.write ("<Table Border = 0 cellspacing = 0 cellpadding = 0>) Doc.write (" <tr> <td valign = middle nowrap>)</p> <p>Doc.write (leftside) / ****** layered /- ************************************************* ******* /</p> <p>IF (Level> 0) // Not rooted node {if (lastnode) // last node {if (foldersnode.length> 3) // Have children {if (foldersnode [0]) // and open {doc.write ("<a href='javascript :top.openbranch(/"" foldersnode[2] "/""'> ") doc.write (" <img border = 0 src = .. / .. / images / Lastnode-.gif width = 16 height = 22> </a> ")} else {// But close doc.write (" <a href = 'javascript: Top.Openbranch (/ " foldersnode [2] " / ") '>") Doc.write ("<img border = 0 src = .. / .. / images / lastnode .gif width = 16 height = 22> </a>")}} else // No children Doc.write ("<imig src = '.. / .. / images / lastnode.gif' width = 16 height = 22>") Leftside = leftside <img src = '.. / .. / images / blank .gif 'width = 16 height = 22> "} else // Non-final node {IF (foldersnode.length> 3) // There are children {if (foldersnode [0]) // and open {doc.write (" < A href = 'javascript: Top.Openbranch (/ " foldersnode [2] " / ")'>") Doc.write ("<img border = 0 src = .. /../IMages/node-.gif width = 16 height = 22> </a> ")} else {// But close doc.write (" <a href = 'javascript: Top.Openbranch (/ "" FoldersNode [2] "/") '> ") doc.write (" <img border = 0 src = .. / .. / images / node .gif width = 16 height = 22> </a> "</p> <p>)}} Else // No children doc.write ("<img src = '.. / .. / images / node.gif' width = 16 height = 22>") Leftside = leftside <img src = '. ./../Images/Vertline.gif 'width = 16 height = 22> "} / ****** Hand icon and hyperlink ********** / doc.write (" <a HREF = '" filename " ID = " foldersnode [1] " & name = " foldersnode [2] "' target = folderframe> <img src = .. / .. / images / closedFolder.gif width = 24 height = 22 border = noBorder> </a> ") / ******** Name and hyperlink ******** / doc.write (" <td valign = middle align = left NOWRAP > ") Doc.write (" <a href='" filename "?id=" foldersnode[1] ""&name=" foldersnode[2] "' target=folderframe <font size = 2 face = 'Song Body'> FoldersNode [2] "</ font> </a>") // The above hyperlink provides ID, name QueryString value ........................................} ELSE // Root Nod {/ ****** Hand-shaped icon with hyperlink ********** / doc.write ("<a href = '" filename "ID =" foldersnode [ 1] "& name =" foldersnode [2] "'target = folderframe> <img src = .. / .. / images / closedFolder.gif width = 24 height = 22 border = noborder> </a>") / ******** Name and hyperlink ******* / doc.write ("<TD VALIG n = middle align = left nowrap> ") Doc.write (" <a href='" filename "?id=" foldersnode[1] "&name=" foldersnode[2] "' target=folderframe " <font size = 2 Face = '</p> <p>Song Body '> " FoldersNode [2] " </ font> </a> ")} Doc.write (" </ Table> ") ///iff (FoldersNode.length> 3 && FoldersNode [0]) / / Have children and open, recursive node {level = level 1 for (i = 3; i <foldersnode.length; i ) if (i == foldersnode.length-1) RedRawnode (FoldersNode [i], doc, level , 1, Leftside) Else RedRawnot (FoldersNode [I], Doc, Level, 0, Leftside)}} // When the user hits the hierarchical /- number, it is called Function ClickonFolderRec (FoldersNode, Foldername) by OpenBranch, Foldername. i = 0</p> <p>IF (FoldersNode [2] == FolderName) {if (FoldersNode [0]) // When turned on, turn it off FoldersNode [0] = 0 else foldersnode [0] = 1} else {for (i = 3; i <foldersnode.length; i ) ClickonFolderRec (FoldersNode [i], foldername}}</p> <p>// Open or close the node (when the user clicks the layered /- number) Function OpenBranch (branchname) {ClickonFolderRec (Folderstree, branchname) TimeoutId = setTimeout ("RedRawtree ()", 100)}</p> <p>// Show tree map function redrawtree () {var DOC = top.treeframe.window.document // Record the current scroll bar position POSX = doc.body.scrollLeft Posy = doc.body.scrolltop doc.open () Doc.write "<body link = '# 0000FF' VLINK = '# 0000FF' alink = '## ff0000' bgcolor = 'White'>") RedRawnot (Folderstree, DOC, 0, 1, ") Doc.close () DOC. Body.scrollleft = poSx doc.body.scrolltop = Posy}</p> <p>Sign in Function Initializetree () {generateTree () redrawtree ()} / ************************** *********************** / </ script> </ head></p> <p><Frameset cols = "220, *" online = "initializetree () FramesPacing =" 1 "> <frame src =" PLEFT.HTM "Name =" TreeFrame "target =" _ self "scrolling =" auto "> <frame src = "PRIGHT.HTM" name = "folderframe" scrolling = "auto"> </ frameset> </ html> <% 'The program is passed under Win2000Server IIS5.0 SQLServer2000. '==================================================== ======== '======= author: Xiachun Tao E-Mail: Bluesky_521@yeah.net ======' =============== ===================================================%> <! - PLLEFT. HTM file content: <html> <body> <p align = center> <font size = 2> is generating a tree map, please wait ... </ font> </ body> </ html> powwwhtm file Content: <html> <body> <p align = center> <font size = 2> Welcome to visit! </ font> </ body> </ html></p> <p>The Content.asp file is written according to your needs yourself.</p> <p>The effect of the program execution is almost the same as the Windows resource manager. ClosedFolder.gif is a small picture of 22 * ​​22, and the rest of the picture is a small picture of 16 * 22; these pictures can be obtained by grasping in the Explorer. -></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-29013.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="29013" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.045</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'uVNYQyL3goCdbbwOjbUtp5UsZAG9f1ANoWr7CGX8UKR1LPpEd6sd_2BYj74ti6Vlj_2BQWBWKkdowPLIUmT15BDEfw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>