Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: change text?

  1. #1
    Regular Coder nolvorite's Avatar
    Join Date
    Dec 2006
    Posts
    176
    Thanks
    7
    Thanked 0 Times in 0 Posts

    change text?

    OK right I got a modification from here that someone requested a few weeks ago. It was supposed to replace text in the userlinks. Since I'm in IPB I find it very useful. But here's the thing

    I try to replace "0 New Messages" to "Inbox[0]" it worked but when I get new PM's it doesn't work like it should. So I rearranged the code but it doesn't work
    Code:
    var mb = document.getElementById("userlinks").getElementsByTagName("a");
    for(bm = 0;bm < mb.length;bm++){
    if(mb[bm].innerHTML=="My Controls"){mb[bm].innerHTML="Preferences"}
    for(fi=0;fi < mb[bm].innerHTML.length;fi++){
    if(fi[mb['bm']].innerHTML==""+fi+" New Messages"){fi[mb[bm]].innerHTML="Inbox "+fi+""}
    }
    }
    ^^ My part there in the code is retarded lol

  • #2
    Regular Coder nolvorite's Avatar
    Join Date
    Dec 2006
    Posts
    176
    Thanks
    7
    Thanked 0 Times in 0 Posts
    anyone?

  • #3
    Regular Coder nolvorite's Avatar
    Join Date
    Dec 2006
    Posts
    176
    Thanks
    7
    Thanked 0 Times in 0 Posts
    omg lol......... any help?

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,437
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    I, for one, do not at all understand what you want. I can't make any sense of that code, at all.
    Code:
    var mb = document.getElementById("userlinks").getElementsByTagName("a");
    for(bm = 0;bm < mb.length;bm++)
    {
        if(mb[bm].innerHTML=="My Controls")
        {
            mb[bm].innerHTML="Preferences"
        }
        // okay...if we just changed "My Controls" to "Preferences" then presumably
        // this particular <a> link is irrelevant...
        // so the code that follows is for *other* <a> links, right?
        //
        for(fi=0;fi < mb[bm].innerHTML.length; fi++)
        // but innerHTML.length is the NUMBER OF CHARACTERS in the text of a given link!
        // so this FOR loop will iterate through the *characters*!
        // fi is a *number* that goes from 0 to however many characters there are in the text of the link
        {
            if(fi[mb['bm']].innerHTML==""+fi+" New Messages")
            // but now you are treating fi as an *ARRAY*!!!  That's what the fi[ ] means!
            // and in any case mb['bm'] will find nothing at all
            // and....well, sorry, but it's just nonsense 
            {
                 fi[mb[bm]].innerHTML="Inbox "+fi+""
            }
        }
    }
    Instead of showing us code that can't possibly be doing anything, show us the actual HTML and then show us what you want it transformed into.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,437
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    Oh...and what is "IPB"??
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    Regular Coder nolvorite's Avatar
    Join Date
    Dec 2006
    Posts
    176
    Thanks
    7
    Thanked 0 Times in 0 Posts
    ok here's my site- The #userlinks is the one right under the ads/menu on the top. When you log in the forum it says "My Controls" - "0 New Messages" etc. in the userlinks. I want to change the text from 0 New Messages to Inbox[0] or Inbox[1] or Inbox[2] if there's 2 new messages

    here's an HTML code if you're logged in as someone named nolvorite
    Code:
    <table width="100%" id="userlinks" cellspacing="6">
       <tr>
        <td><strong>Logged in as:  <a href='http://stereo.b1.jcink.com/index.php?showuser=1'>ǝтιɹoʌlou</a></strong> ( <a href='http://stereo.b1.jcink.com/index.php?act=Login&amp;CODE=03&amp;key=1a4dcf998504e8aa43a9a5cfd6757336'>Log Out</a>&middot; <b><a href='http://stereo.b1.jcink.com/index.php?act=modcp'>Mod CP</a></b>  )</td>
    
        <td align='right'>
          <b><a href='http://stereo.b1.jcink.com/index.php?act=UserCP&amp;CODE=00' title='Edit my settings, such as signature, avatar and more...'>My Controls</a></b> &middot; 
    
    <!-- HHHHHHHHHHHHHnote: I want to change this from 0 New Messages to Inbox[0],1 New Messages if it's Inbox[1], or 2 Messages to Inbox[2] If there's 0/one/two new PM's (Private Messages) using javascript--><a href='http://stereo.b1.jcink.com/index.php?act=Msg&amp;CODE=01'>0 New Messages</a>
    
          &middot; <a href='http://stereo.b1.jcink.com/index.php?act=Search&amp;CODE=getnew'>View New Posts</a> &middot; <a href='javascript:buddy_pop();' title='View posts since your last visit, moderator lists and more...'>My Assistant</a> &middot; <a href="javascript:window.open('index.php?showuser=1&CODE=friends','Friends','width=620,height=460,resizable=yes,scrollbars=yes');void(0);">My Friends</a><br />
    
    </td>
       </tr>
      </table>
    <!-- HHHHHHHHHHHHHnote: I want to change this from 0 New Messages to Inbox[0], Inbox[1], or Inbox[2] If there's one/two new PM's (Private Messages) using javascript--><a href='http://stereo.b1.jcink.com/index.php?act=Msg&amp;CODE=01'>0 New Messages</a>
    Last edited by nolvorite; 06-23-2010 at 06:36 PM.

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,437
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    Not to ask a dumb *** question, but...Why not go into the PHP and change it there???

    Surely would be simpler than doing this ex post fact stuff.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,437
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    Okay...here's my effort. Could be more efficient, but seems to work:
    Code:
    <html>
    <head>
    <script>
    var check1 = /My Controls/;
    var check2 = /(\d+) New Messages/;
    
    function fixit( )
    {
        var links = document.getElementsByTagName("a");
        for ( var n = 0; n < links.length; ++n )
        {
            a = links[n];
            a.innerHTML = a.innerHTML.replace( check1, "Preferences" );
            a.innerHTML = a.innerHTML.replace( check2, "Inbox[$1]" );
        }
    }
    </script>
    </head>
    <body onload="fixit()">
    
    <table width="100%" id="userlinks" cellspacing="6">
       <tr>
        <td><strong>Logged in as:  <a href='http://stereo.b1.jcink.com/index.php?showuser=1'>ǝтιɹoʌlou</a></strong> ( <a 
    
    href='http://stereo.b1.jcink.com/index.php?act=Login&amp;CODE=03&amp;key=1a4dcf998504e8aa43a9a5cfd6757336'>Log Out</a>&middot; <b><a 
    
    href='http://stereo.b1.jcink.com/index.php?act=modcp'>Mod CP</a></b>  )</td>
    
        <td align='right'>
          <b><a href='http://stereo.b1.jcink.com/index.php?act=UserCP&amp;CODE=00' title='Edit my settings, such as signature, avatar and 
    
    more...'>My Controls</a></b> 
          &middot; 
          <a href='http://stereo.b1.jcink.com/index.php?act=Msg&amp;CODE=01'>0 New Messages</a>
          &middot; <a href='http://stereo.b1.jcink.com/index.php?act=Search&amp;CODE=getnew'>View New Posts</a>
          &middot; <a href='javascript:buddy_pop();' title='View posts since your last visit, moderator lists and more...'>My Assistant</a>
          &middot; <a ref="javascript:window.open('index.php?showuser=1&CODE=friends','Friends', 
                                                  'width=620,height=460,resizable=yes,scrollbars=yes');void(0);"
    
                   >My Friends</a><br />
       </td>
       </tr>
      </table>
    </body>
    </html>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #9
    Regular Coder nolvorite's Avatar
    Join Date
    Dec 2006
    Posts
    176
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Not to ask a dumb *** question, but...Why not go into the PHP and change it there???

    Surely would be simpler than doing this ex post fact stuff.
    that's because my forum's hosted on a free host and I can't directly edit the HTML template because it's disabled to edit because they want to save some serious bandwidth.

    anyways it worked, I love you man. I could never do that


  •  

    Posting Permissions

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