Tricky logic stuff. Where are the smart people???

Results 1 to 3 of 3

Thread: Tricky logic stuff. Where are the smart people???

  1. #1
    Kentium Guest

    Default Tricky logic stuff. Where are the smart people???

    Here&#039;s the deal-<BR><BR>I&#039;m working on a new home page for our web site that will have three different "slots" for scenarios of services we offer.<BR><BR>The slots are just table cells with space for an image and text to describe the scenarios.<BR><BR>We have two services- Service 1 with 2 scenarios, and Service 2 with 7 scenarios.<BR><BR>What I want to do is have one of our slots show one of the Service 1 scenarios, and have the other two slots each show one of the Service 2 scenarios.<BR><BR>Here&#039;s the kicker- I want everything to pull up randomly. I want the scenarios to pull up randomly, and to appear in the different slots randomly.<BR><BR>I&#039;ve got the code to make some of the random stuff happen, but I can&#039;t figure out the logic to get the scenarios to randomly show up in the different slots. Make sense?<BR><BR>&#039;do the randomizer schtuff<BR>Dim randompc, randomwc1, randomwc2<BR><BR>Randomize &#039; Initialize random-number generator.<BR><BR>randompc = Int((2 * Rnd) + 1) &#039; Generate random value between 1 and 2<BR>randomwc1 = Int((7 * Rnd) + 1) &#039; Generate random value between 1 and 7<BR>randomwc2 = Int((7 * Rnd) + 1) &#039; Generate random value between 1 and 7<BR><BR>&#039; make sure wc1 and wc2 don&#039;t match<BR>while randomwc2 = randomwc1<BR>randomwc2 = Int((7 * Rnd) + 1)<BR>wend<BR><BR><BR><BR>&#039;build out the scenarios<BR>dim pcimg, pctext, wc1img, wc2img, wc1text, wc2text<BR><BR>Select Case randompc<BR> Case 1<BR> randompc = 1<BR> (render the image and text for service 1 scenario 1)<BR> Case 2<BR> randompc = 2<BR> (render the image and text for service 1 scenario 2)<BR>End Select<BR><BR>Select Case randomwc1<BR> Case 1<BR> randomwc1 = 1<BR> (render the image and text for service 2 scenario 1)<BR> Case 2<BR> randomwc1 = 2<BR> (render the image and text for service 2 scenario 2)<BR> etc. etc...for all 7 scenarios<BR>End Select<BR><BR>Case Select<BR><BR>---do the same stuff for Service 2<BR><BR>End Select<BR><BR>You&#039;ll notice that I have two blocks of the same code for Service 2...there&#039;s probably a better way to do this too, but I&#039;m not sure how.<BR><BR>Can anyone provide some illumination on this? Thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: Tricky logic stuff. Where are the smart peopl

    What about using an array? If you built an array such as below either at the start of your page, or as a session variable in your Global.asa file, then the block would be easy to get at if you needed to make changes in the future.<BR><BR>Manually making the array might look like:-<BR><BR><BR>ImageSlot1(1)="/images/anImage1.gif"<BR>TextSlot1(1)="Text for Slot 1, Scenario 1"<BR>ImageSlot1(2)="/images/anImage2.gif"<BR>TextSlot1(2)="Text for Slot 1, Scenario 2"<BR><BR>ImageSlot2or3(1)="/images/anotherImage1.gif"<BR>TextSlot2or3(1)="Text for Slot 2, Scenario 1"<BR>ImageSlot2or3(2)="/images/anotherImage2.gif"<BR>TextSlot2or3(2)="Text for Slot 2, Scenario 2"<BR>(etc for seven text/image pairs)<BR><BR>Then, in your code all you have to do is come up with the three indexes, one each for each slot. So..<BR><BR>IndexSlot1=Int((2 * Rnd) + 1) <BR>IndexSlot2=Int((7 * Rnd) + 1)<BR>IndexSlot3=Int((7 * Rnd) + 1)<BR>do while indexSlot3=indexSlot2<BR> IndexSlot3=Int((7 * Rnd) + 1)<BR>loop<BR><BR>(HMTL bit...)<BR>(for slot 1)<BR>&#060;img src="&#060;%=ImageSlot1(IndexSlot1)%&#062;"&#062;< BR>(for slot 2)<BR>&#060;img src="&#060;%=ImageSlot2or3(IndexSlot2)%&#062;"&#06 2;<BR>(for slot 3)<BR>&#060;img src="&#060;%=ImageSlot3or3(IndexSlot3)%&#062;"&#06 2;<BR><BR>You&#039;d do a similar thing to get your text out of the array.<BR><BR>Is this any use? Happy coding...<BR><BR><BR>

  3. #3
    Kentium Guest

    Default that looks real good

    thanks...I should have plenty to play with now!<BR><BR>

Posting Permissions

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