July 20th, 2011, 12:22 AM
Displaying ad in the form using RandRange
I have 3 images(Ads) which should be distributed 33%, 33% and 34% (100%)
The images should be displayed one after the other in the form.
Could anyone help me how to place the ad in my coldfusion form page.
something could be like
<cfset random = RandRange(33, 100)>
<cfif random eq 34>
<iframe ....> src1</iframe>
<cfelseif random eq 33>
<iframe ....> src2</iframe>
<cfelseif random eq 33> -------?
<iframe ....> src3</iframe>
when user clicks the form each time the image(ad) also should change each time.
Thanks in advance!
July 20th, 2011, 08:02 PM
Hardcoding these is very limiting, since any time you add more, remove some, or change the image url you have to change the code. I'd put them in a database and select and just query for a random image.
July 21st, 2011, 06:43 AM
Thanks for your reply.
I'm told not to use Database for this purpose.
I tried to use <cfset random = RandRange(1,3)>
<cfif random is "1">
<Cfelseif random is "2">
<cfelseif random is "3>
From the above statement - it works well, but often the images repeating 2 or 3 times which I want to avoid. Instead of RandRange is there any method(way) which possible to display images one after the other continuously like looping for each click?
Originally Posted by kiteless
July 21st, 2011, 07:48 PM
If you don't actually want it random and want it to be sequential, sure. Just set up an application-scope variable that starts at 1, and increment it each time the page loads. When it gets to 3 and runs the third image, set it back to 1 so the count starts over.