1. Senior Member
Join Date
Dec 1969
Posts
162

I am trying to finilize a banner rotation app. But as always I SUCK at math. I know what needs to happen I just have no Idea how. Ive looked everywhere ask in many boards including this one but no one can answer my question.<BR><BR>I have four banners:<BR><BR>banner id =1<BR>banner weight =7<BR>banner id =5<BR>banner weight =1<BR><BR>banner id =6<BR>banner weight =10<BR><BR>banner id =13<BR>banner weight =4<BR><BR>total weight of all banners = 22<BR><BR><BR>How do I know which one is next. All thse are in a getrow Array<BR>I loop thru the array to get the total wieght of all banners but im stuck right here and its driving me freaking NUTS!!!! Please help.of course these banners are not set in stone on day there can be 10 another there can be 0 <BR><BR><BR>Does anyone know of a tutorial code snippet anything that would show me how Ad banner weights are coded?<BR><BR>Please help im really trying to understand this but I cannot figure this out myself I just dont have the knowledge<BR>

2. Senior Member
Join Date
Dec 1969
Posts
935

## what do you want to do?

I did not understand from your message what you want to do.<BR>and do you need it in a client side scripting or server side?

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## Given how your data is stored...

...I&#039;d say simple is best.<BR><BR>You say you have already looped through to get the total weight. GOOD!<BR><BR>SO then:<BR><BR>&#060;%<BR>totalWeight = ... from your loop ...<BR><BR>Randomize &#039; don&#039;t forget this<BR><BR>choice = Int( RND * totalWeight ) &#039; note this is zero to totalWeight-1<BR><BR>soFar = 0 &#039; initialize our weight counter<BR><BR>For row = 0 To UBound( yourArray, 2 )<BR> soFar = soFar + yourArray( COL_WEIGHT, row ) &#039; The key to it!<BR> If soFar &#062; choice Then<BR> chosenRow = row<BR> Exit For<BR> End If<BR>Next<BR><BR>&#039; when you get here chosenRow tells you which to use<BR><BR>%&#062;<BR><BR>Simple as that. Play with it a bit. See if it doesn&#039;t make sense to you! <BR><BR> <BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## He said...

&#062; All thse are in a getrow Array <BR><BR>Since GetRow would be server side, I assumed a server side answer. Hmmm...I guess we&#039;ll find out.<BR><BR>

5. Senior Member
Join Date
Dec 1969
Posts
162

## RE: Given how your data is stored...

Awsome thats great thanks.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•