Hi,
I've tried with this since 5pm. It's now 2am and still not working. I am trying to display some tags in a tagcloud. Originally it was working with a one dimension array but I needed the id for the hyperlink so I change to a 2 dimension array. The problem is that only the last item in the array is rendered. For Some reason my array is not preserved.
Here is my code...seriously I really tried with this. Kindly assist. -
-
<%
-
-
Function tagCloud()
-
-
Dim aDigits, tempTagHolder, biggestNum
-
Dim aDynamic
-
-
ReDim aDynamic(1,0)
-
-
Set conn = server.createobject("adodb.connection")
-
-
Set objRs = server.CreateObject("adodb.recordset")
-
-
conn.open strConn
-
-
sql = "execute GetTagCloud"
-
-
set objRs = conn.Execute(sql)
-
-
While Not objRs.EOF
-
count = objRs("tag_count")
-
objRs.MoveNext
-
Wend
-
-
'Get next table with tags
-
Set objRs = objRs.NextRecordset()
-
-
-
While Not objRs.EOF
-
-
-
For i = 0 to count
-
-
ReDim Preserve aDynamic(1,i) <-----------------------------Here
-
aDynamic(0,i) = objRs.Fields.Item("tag_id").value
-
aDynamic(1,i) = objRs.Fields.Item("tag_Name").value
-
-
Next
-
-
objRs.MoveNext
-
-
Wend
-
-
objRs.Close()
-
-
'For b = 0 to Count
-
'response.write(aDynamic(1,b))
-
'Next
-
-
-
Call DualSorter(aDynamic,1)
-
-
-
'Get the highest tag
-
biggestNum = 0
-
lastTag = aDynamic(1,0)
-
For i=0 to count
-
If lastTag = aDynamic(1,i) Then
-
tagCount = tagCount+1
-
Else
-
If tagCount >= biggestNum Then
-
biggestNum = tagCount
-
End If
-
tagCount = 1
-
End If
-
lastTag = aDynamic(1,i)
-
If i = count Then
-
If tagCount >= biggestNum Then
-
biggestNum = tagCount
-
End If
-
End If
-
Next
-
-
'Output Tags
-
Dim lastTag, tagCount, i, newTag, loopHolder, tempNewTag, sHTML
-
lastTag = aDynamic(1,0)
-
tagCount=0
-
-
sHTML = "<div>"
-
-
For i=0 to count
-
If lastTag = aDynamic(1,i) Then
-
tagCount = tagCount+1
-
Else
-
sHTML = sHTML & "<a href=""?tag="&lastTag&""">"&renderTag(lastTag,tagCount,biggestNum)&"</a>"
-
tagCount = 1
-
End If
-
lastTag = aDynamic(1,i)
-
If i = count Then
-
sHTML = sHTML & "<a href=""?tag="&lastTag&""">"&renderTag(lastTag,tagCount,biggestNum)&"</a>"
-
End If
-
Next
-
-
Response.Write(sHTML&"</div>")
-
-
End Function
-
-
Function renderTag(tagName,tagCount,biggestNum)
-
-
...Just applying size style
-
-
End Function
-
-
-
Sub DualSorter( byRef arrArray, DimensionToSort )
-
Dim row, j, StartingKeyValue, StartingOtherValue, _
-
NewStartingKey, NewStartingOther, _
-
swap_pos, OtherDimension
-
Const column = 1
-
-
' Ensure that the user has picked a valid DimensionToSort
-
If DimensionToSort = 1 then
-
OtherDimension = 0
-
ElseIf DimensionToSort = 0 then
-
OtherDimension = 1
-
Else
-
'Shoot, invalid value of DimensionToSort
-
Response.Write "Invalid dimension for DimensionToSort: " & _
-
"must be value of 1 or 0."
-
Response.End
-
End If
-
-
For row = 0 To UBound( arrArray, column ) - 1
-
'Start outer loop.
-
-
'Take a snapshot of the first element
-
'in the array because if there is a
-
'smaller value elsewhere in the array
-
'we'll need to do a swap.
-
StartingKeyValue = arrArray ( row, DimensionToSort )
-
StartingOtherValue = arrArray ( row, OtherDimension )
-
-
' Default the Starting values to the First Record
-
NewStartingKey = arrArray ( row, DimensionToSort )
-
NewStartingOther = arrArray ( row, OtherDimension )
-
-
swap_pos = row
-
-
For j = row + 1 to UBound( arrArray, column )
-
'Start inner loop.
-
If arrArray ( j, DimensionToSort ) < NewStartingKey Then
-
'This is now the lowest number -
-
'remember it's position.
-
swap_pos = j
-
NewStartingKey = arrArray ( j, DimensionToSort )
-
NewStartingOther = arrArray ( j, OtherDimension )
-
End If
-
Next
-
-
If swap_pos <> row Then
-
'If we get here then we are about to do a swap
-
'within the array.
-
arrArray ( swap_pos, DimensionToSort ) = StartingKeyValue
-
arrArray ( swap_pos, OtherDimension ) = StartingOtherValue
-
-
arrArray ( row, DimensionToSort ) = NewStartingKey
-
arrArray ( row, OtherDimension ) = NewStartingOther
-
-
End If
-
Next
-
End Sub
-
-
-
%>
-
4 2098
I didn't look into it really deep, but your 2D array only has two possible values in one dimension. Why don't you just use 2 different 1D arrays? Just a thought.
Jared
I didn't look into it really deep, but your 2D array only has two possible values in one dimension. Why don't you just use 2 different 1D arrays? Just a thought.
Jared
Can you please explain? If I use 2 separate arrays how can I get them to sort on the same matching order?
Can you please explain? If I use 2 separate arrays how can I get them to sort on the same matching order?
This is really easy. Say you have a list of people's names and a second list of genders. so the first list names(9) contains these: - gina
-
gordon
-
alexander
-
peter
-
debora
-
misty
-
conan
-
subashini
-
ali
-
germain
and the other list genders(9) looks like this: - fem
-
mas
-
mas
-
mas
-
fem
-
fem
-
mas
-
fem
-
mas
-
mas
then you can sort them like this: - dim i, j, tempName, tempGend
-
-
for i = 8 to 0 step -1
-
for j = 0 to i
-
tempName = names(j+1)
-
tempGend = genders(j+1)
-
if names(j)>tempName then
-
names(j+1) = names(j)
-
names(j) = tempName
-
genders(j+1) = genders(j)
-
genders(j) = tempGend
-
end if
-
next
-
next
-
-
for each i in names
-
response.write names(i) & ": " & genders(i) & "<br>" & vbNewLine
-
next
notice, I sort both arrays according to the name, I never look at the value of the second array, except that I move it to match the other array which I sorted. In the end the newly arranged array has the right gender with the right name. Let me know if this helps.
Jared
This is really easy. Say you have a list of people's names and a second list of genders. so the first list names(9) contains these: - gina
-
gordon
-
alexander
-
peter
-
debora
-
misty
-
conan
-
subashini
-
ali
-
germain
and the other list genders(9) looks like this: - fem
-
mas
-
mas
-
mas
-
fem
-
fem
-
mas
-
fem
-
mas
-
mas
then you can sort them like this: - dim i, j, tempName, tempGend
-
-
for i = 8 to 0 step -1
-
for j = 0 to i
-
tempName = names(j+1)
-
tempGend = genders(j+1)
-
if names(j)>tempName then
-
names(j+1) = names(j)
-
names(j) = tempName
-
genders(j+1) = genders(j)
-
genders(j) = tempGend
-
end if
-
next
-
next
-
-
for each i in names
-
response.write names(i) & ": " & genders(i) & "<br>" & vbNewLine
-
next
notice, I sort both arrays according to the name, I never look at the value of the second array, except that I move it to match the other array which I sorted. In the end the newly arranged array has the right gender with the right name. Let me know if this helps.
Jared
Ah ha...This looks interesting. Let me try this.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: lkrubner |
last post by:
I apologize for being a bit dense, but I'm trying to wrap my head
around the sentence
"Its purpose is to allow processes to register with a cloud to be
notified of updates to the channel,...
|
by: Leszek |
last post by:
Hi.
Is it possible in javascript to operate on an array without knowing how mamy
elements it has?
What i want to do is sending an array to a script, and this script should
add all values from...
|
by: kevincw01 |
last post by:
Anyone have a clever way to retrieve for example, items 0-29 from an
array of size N>29, in random order? The catch is that I dont want to
print any items more than once and I dont want to miss...
|
by: yawnmoth |
last post by:
According to <http://www.rssboard.org/rss-
specification#ltcloudgtSubelementOfLtchannelgt>, " specifies a
web service that supports the rssCloud interface which can be
implemented in HTTP-POST,...
|
by: Aaron Watters |
last post by:
So, in between skiing runs I noticed
a Business Week cover story on
"cloud computing". The article had
lots of interesting information in it like
about how somebody's mom used to
be an airline...
|
by: Bill Fuller |
last post by:
Is anyone familier with Amazon's Elastic compute cloud for hosting
applications? It appears to be UNIX based. I am wondering if anyone is
familier with something similar for utility computing for...
|
by: shapper |
last post by:
Hello,
What is the correct markup and CSS styles to create a Tag Cloud?
Should I place each tag inside a list item of an ordered list and
style the list item with a different CSS class...
|
by: knorth |
last post by:
The DataServices World conference offers a program for those
interested in technology for data integration and data access, with
emphasis on service-oriented architecture (SOA), web-oriented...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |