Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Javascript array vs VB array

Author  Topic 

MarkGG
Yak Posting Veteran

53 Posts

Posted - 2005-08-23 : 08:44:23
Hi.

I am trying to make an org chart webpage that would work much similar to this page

[url]http://www.aasoftech.com/Demo1/FullChart.html[/url]

After some brainstorming with my boss we decided that it would be best to put everything into a 2D array of values. The array would look like so:

[First column - Chart Row #] [Second Column - Identifies Entry on that row] [Third Column - Information about that entry]

So for example [0][0][0] would mean the height of the chart was 0, the entry was the first of the row, and the last zero could represent the name of the entry lets say. A number of [1][1][3] would mean it is the second row, second object, and three could mean the start date. etc etc....

Would I be better off putting my information into a VB array, or should I use the Javascript 2D array?

The code I have roughly looks like this:


<html>
<body>

<script language="Javascript">
<!-- Create the arrays -->
var a = new Array(2);
a[0] = new Array(3);
a[1] = new Array(2);

<%
'Select all of the objects from the DB and while still not end of file
select * from PROJECTS
do while not objRS.EOF
%>
<!-- 'A for loop to populate the arrays -->
for (i = 0; i < a.length; i++) {
for (j = 0; j < a[i].length; j++) {
for (k=0; k < a[j].length; k++) {
document.write("a[",i,"][",j,"][",k,"] = ", a[i][j][k], "<BR>");
}
}
}


</script>

</body>
</html>


I know the JS for loop doesn't do anything and it is writing the array not taking data in, but this is rough. Would this work for what I want or should I write this to a VB array?

Has anyone ever tried something like this before and have any suggestions or ideas?

Thanks
-Mark

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-23 : 09:27:27
well if you want to do it like that use a JS array.

i'd go with xml format myself for this...

Go with the flow & have fun! Else fight the flow
Go to Top of Page

MarkGG
Yak Posting Veteran

53 Posts

Posted - 2005-08-29 : 13:46:30
Ok well how about this, I have the database and table set-up but when I run this I don't get anything to display:

<html>
<body>

<%
ON ERROR RESUME NEXT
Dim con,sql,constring, rs
Set con = Server.CreateObject("ADODB.Connection")
%>

<!-- #include file="dbConnect.ssi" -->

<%
set objRS=Server.CreateObject("ADODB.recordset")
'I open my connection
con.Open dbConnect
%>

<script language="Javascript">
<!-- Create the arrays -->
var a = new Array(

<%
'Select all of the objects from the DB and while still not end of file
SQL = "select * from PROJECT"
objRS.Open SQL, dbConnect
do while not objRS.EOF
%>

newArray(<%=objRS("proj_name")%>, <%=objRS("proj_id")%>, <%=objRS("proj_parent")%>, <%=objRS("purpose")%>, <%=objRS("description")%>, <%=objRS("start_date")%>, <%=objRS("EstComp_date")%>);

<%
objRS.movenext
Loop
objRS.close
con.close
set con = nothing
%>

);

<!-- 'A for loop to populate the arrays -->
for (i = 0; i < a.length; i++) {
for (j = 0; j < a[i].length; j++) {
document.write("a[",i,"][",j,"] = ", a[i][j], "<BR>");
}
}
}

</script>

</body>
</html>
Go to Top of Page
   

- Advertisement -