Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    New Coder
    Join Date
    Jul 2010
    Thanked 0 Times in 0 Posts

    nevermind, I figured it out

    go to this page and view source, there is my and maybe your answer


  2. #17
    Senior Coder durangod's Avatar
    Join Date
    Nov 2010
    southwestern USA
    Thanked 47 Times in 45 Posts
    From the previous page i used trinithis code and then removed some divs and groups that i did not need.
    Quote Originally Posted by Trinithis View Post
    For a less flexible, but easy(er) to understand code that uses true opacity rather than color changes:
    here is what i have:

    <!-- added for text rotator -->
    <script type="text/javascript">
    function rotateText(el, textGroup) {
      setOpacity(el, 0);
      var t = rotateText.texts[textGroup];
      var t = t[Math.floor(Math.random() * (t.length - 1))];
      el.innerHTML = t;
      unfadeText(el, textGroup);
    rotateText.texts = 
      quotes: ["test1...",
    function setOpacity(el, value) {
      el.style.opacity = value / 100;
      el.style.filter = "alpha(opacity=" + value + ")";
    function unfadeText(el, tg) {
      var v = el.style.opacity * 100 + 1;
      if(v > 100) {
        setOpacity(el, 100);
        setTimeout(bundleFunction(null, fadeText, [el, tg]), 10000);  /* number of seconds, this is 10 sec */
      setOpacity(el, v);
      setTimeout(bundleFunction(null, unfadeText, [el, tg]), 10);
    function fadeText(el, tg) {
      var v = el.style.opacity * 100 - 1;
      if(v < 0) {
        setOpacity(el, 0);
        rotateText(el, tg);
        //or... setTimeout(bundleFunction(null, rotateText, [el, tg]), NUMBER);
      setOpacity(el, v);
      setTimeout(bundleFunction(null, fadeText, [el, tg]), 10);
    function bundleFunction(context, func, args) {
      context = context || null;
      if(typeof func == "string" && context)
        func = context[func];
        args = [];
      else if(!(args instanceof Array))
        args = [args];
      return function() {
        return func.apply(context, args);
    <!-- end text rotator -->
    then on the page i have

    <div style="font-size:small;margin:0px 10px 0px 10px;" id="quotes"></div>
    <script type="text/javascript">
    rotateText(document.getElementById("quotes"), "quotes");

    I used this and it works, but since im not using all groups as in the original, i dont know if i need the groups configured and value passed? I have been watching this now for over an hour and restarted it several times during to see if the loop changed.

    Im seeing test 1 thru 4 show fine, test 4 repeats more than others and many times it repeats right after itself, i counted 3x in a row once.
    Test 5 never shows, i have not seen it once in over an hour of testing so not sure whats up with that.

    Is there an easy mod so that it does not repeat the quote it just showed? And do you see anything that would cause test5 not to show at all?


    Another update here. I went from 5 to 11 options thinking there were not enough to stop the consecutive repeats and Changed this from math floor to math round and that seems to have fixed the issue with test5

    var t = group[Math.round(Math.random() * (group.length - 1))];
    UPDATE i think i got it..But who knows. This should stop the consecutive random
    I change t to group maybe that will help.

    //grab current text
        var sametext = document.getElementById('quotes').innerHTML;
       //get new text
       var group = rotateText.texts[textGroup];
       var t = group[Math.round(Math.random() * (group.length - 1))]; //chose round on this one
       //if they are the same then get another one
       if(sametext == t)
         //alert("text is the same" + sametext);   
         var group = rotateText.texts[textGroup];
         var t = group[Math.floor(Math.random() * (group.length - 1))]; //chose floor for this one
          }//close if
    You can see the alert trap that i added (commented out now) that shows me the current text on the page and with that i verified that t (the new output) is different once the alert is trapped. So it is working and it does grab a dif value if its the same.
    Ok im done with this, sorry to do some an old thread but i didnt want to keep refering to it.

    Last edited by durangod; 12-30-2012 at 09:48 PM. Reason: I changed the line for current text to added the innerHTML i was not grabbing the text before which is why it was not working

Page 2 of 2 FirstFirst 12

Posting Permissions

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