Web Analytics Made Easy -
StatCounter Expandable Menus (not sure how to word it) - CodingForum

Announcement

Collapse
No announcement yet.

Expandable Menus (not sure how to word it)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Expandable Menus (not sure how to word it)

    What Im trying to implement is when you click on the Text link, instead of getting a submenu, you get like a paragraph or two of text.

    This will not be on the left/right side of my webpage, but will be in the middle frame. Using it to help minimize the amount of pages Ill need... but cant figure out how to make it happen.

    Any help would be greatful.

  • #2
    Something like this ?

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    script>
    var 
    = new Array()
    t[0] = new Array('id1','text here for link 1');
    t[1] = new Array('id2','another text here for link 2');
    t[2] = new Array('id3','link 3 and text here');
    function 
    bla(a){
    for(
    i=0;i<t.length;i++){
    if(
    t[i][0] == a){
    document.getElementById('txt').innerHTML t[i][1];
    }
    }
    }
    </
    script>
    </
    head>

    <
    body>
    <
    div id="txt" style="position:absolute; left: 100; width: 150; height: 30; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000;"></div>
    <
    a href="#" id="id1" onclick="bla(this.id)">Link 1</a><br>
    <
    a href="#" id="id2" onclick="bla(this.id)">Link 2</a><br>
    <
    a href="#" id="id3" onclick="bla(this.id)">Link 3</a>
    </
    body>
    </
    html
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

    Comment


    • #3
      Ahh that will work just fine! Thanks a lot man, saved me a bunch of time and pages.

      Thanks again!

      Comment


      • #4
        ...and, if you have a lot of links, maybe is a good ideea to stop the loop after the condition is fulfiled

        document.getElementById('txt').innerHTML = t[i][1];break
        KOR
        Offshore programming
        -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

        Comment


        • #5
          You could have also implemented it without looping.
          <html>
          <head>
          <script>
          var t = new Array()
          t[0] = 'text here for link 1';
          t[1] = 'another text here for link 2';
          t[2] = 'link 3 and text here';

          function bla(a){
          document.getElementById('txt').innerHTML = t[a];
          return false;
          }
          </script>
          </head>
          <body>
          <div id="txt" style="position:absolute; left: 100; width: 150; height: 30; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000;"></div>
          <a href="#" onclick="return bla(0)">Link 1</a><br>
          <a href="#" onclick="return bla(1)">Link 2</a><br>
          <a href="#" onclick="return bla(2)">Link 3</a>
          </body>
          </html>
          Glenn
          vBulletin Mods That Rock!

          Comment


          • #6
            Thanks for the extra help, its very much appreciated.

            But the text that I need to have shown, after the link is clicked, is pretty big text. Its almost a few paragraphs in length. Now is there a way to show these huge paragraphs in the

            t[0] = 'text here for link 1';

            ??

            I rearranged the text box, so that it is underneath the links, and I also made the box bigger so that it could compensate for the large text.

            Comment


            • #7
              It's the same thing really. You can add tags too if you want.
              Code:
              <html>
              <head>
              <script>
              var t = new Array()
              t[0] = '<p>Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. </p><p>Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. Some enormous text. </p>';
              t[1] = '<p>SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. </p><p>SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. v</p>';
              t[2] = '<p>Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. </p><p>Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. </p>';
              
              function bla(a){
              document.getElementById('txt').innerHTML = t[a];
              return false;
              }
              </script>
              </head>
              <body style="text-align: center;">
              <a href="#" onclick="return bla(0)">Link 1</a>
              <a href="#" onclick="return bla(1)">Link 2</a>
              <a href="#" onclick="return bla(2)">Link 3</a><br>
              <div id="txt" style="width: 60%; background-color: #CCCCCC;"></div>
              
              </body>
              </html>
              Shawn

              Comment


              • #8
                Ahh.. I knew that. Sadly, I probably coulda figured that out by testing it all out.

                Are you able to put all types of tags in it.. such as <table></table> and stuff like that? If so, that would be awesome.. gonna try it out now actually.

                Thanks again for the help!

                Comment


                • #9
                  probably not ANY tag.
                  <html> wouldn't work I don't think. <table> would work though I think...
                  Shawn

                  Comment


                  • #10
                    Well I didnt mean tags like that... Im clearly aware that that particular tag, as well as <head> and <title> wouldnt work. Ill just test to see what does and doesnt work.

                    Comment


                    • #11
                      PHP Code:
                      <html>
                      <
                      head>
                      <
                      script>
                      var 
                      = new Array()
                      t[0] = '<p>Once you place your house, you will want furniture and knick-knacks. About house addons: You can 
                      unlock them if you want to move them around, put where you want, and lock them down again (after 
                      theyve been placed). Also, in Britain at the Provisioners (and elsewhere) you will find an npc 
                      called "Decorator". You can buy all sorts of neat things to dress up your house. There are 4 
                      places to find cool stuff for your house: NPC Decorators, NPC Bakers, Player Carpenters and GMs. 
                      The NPC decorators have a lot of items that can not be crafted by players like decorative weapon 
                      racks, decorative shields, portraits, spider webs and more. The table below shows items that can 
                      be obtained from other sources.</p>
                      <p>Farmers now carry seeds that will create plants. When you use a flower seed, youll be able to 
                      choose from a few different types of flowers that you can plant. If you select a flower, a flower 
                      of that type will appear locked down at your feet (using 1 house lockdown slot.)
                      <p>To removed a flower, unlock it like you would any other item ("I wish to lock this down", or "I wish 
                      to release this".) You will not receive a flower seed back (after all, you ripped the plant up by the 
                      roots. Its dead.)</p>
                      <p>When you use a flower seed (available from farmer NPCs), you now get a targeting cursor. If you target 
                      yourself, youll plant the flowers where youre standing. If you target a pot or vase, youll plant the 
                      flowers in that Sometimes looks pretty bad, sometimes looks pretty good. Youll just have to 
                      experiment.) If you target anything else, youll cancel the planting. You now have to lock down the 
                      vase where you want it. When you target the vase, the flowers will appear on top. If you target 
                      yourself, the flowers will appear where you are standing.</p>
                            <table cellspacing="0" border="1" bgcolor="#999999">
                              <tr>
                                <td align="middle" width="20%">GM placed Stuff </td>
                                <td align="middle" width="20%">Carpenter Deeds </td>
                                <td align="middle" width="20%">Baker Deeds </td>
                                <td align="middle" width="20%">Blacksmith Deeds </td>
                                <td align="middle" width="20%">Bee Keeper </td>
                              </tr>
                              <tr>
                                <td>Fences (5K per tile) </td>
                                <td>Small Forge </td>
                                <td>Ovens </td>
                                <td>Outside lamp posts </td>
                                <td>New Beehives </td>
                              </tr>
                              <tr>
                                <td>Teleporters 1 </td>
                                <td>Anvil </td>
                                <td>Fire Place </td>
                                <td></td>
                                <td></td>
                              </tr>
                              <tr>
                                <td></td>
                                <td>Fighting Dummy </td>
                                <td></td>
                                <td></td>
                                <td></td>
                              </tr>
                              <tr>
                                <td></td>
                                <td>Pick Pocket Dip </td>
                                <td></td>
                                <td></td>
                                <td></td>
                              </tr>
                              <tr>
                                <td></td>
                                <td>Large Bed </td>
                                <td></td>
                                <td></td>
                                <td></td>
                              </tr>
                              <tr>
                                <td></td>
                                <td>Small Bed </td>
                                <td></td>
                                <td></td>
                                <td></td>
                              </tr>
                              <tr>
                                <td></td>
                                <td>Loom </td>
                                <td></td>
                                <td></td>
                                <td></td>
                              </tr>
                              <tr>
                                <td></td>
                                <td>Spinning Wheel </td>
                                <td></td>
                                <td></td>
                                <td></td>
                              </tr>
                              <tr>
                                <td></td>
                                <td>Grinding Mills </td>
                                <td></td>
                                <td></td>
                                <td></td>
                              </tr>
                            </table>
                      <p>1 : Teleporters cost 10% of the house and are left to GM discretion. Not all houses need 
                      teleporters. For example, the 150K tower would not need teleporters where some static houses 
                      would need them to gain access to locations such as the roof (not available on all static 
                      houses).</p>'
                      ;
                      t[1] = '<p>SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. </p><p>SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. SOme other huge text. v</p>';
                      t[2] = '<p>Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. </p><p>Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. Another text. </p>';
                      t[3] = '';
                      t[4] = '';
                      t[5] = '';
                      function 
                      bla(a){
                      document.getElementById('txt').innerHTML t[a];
                      return 
                      false;
                      }
                      </
                      script>
                      </
                      head>
                      <
                      body style="text-align: left;" bgcolor="black">
                      <
                      font color="#FF0000">
                      <
                      center><h2>Housing</h2></center>
                      <
                      p>One of the more enjoyable aspects of the UO derived virtual worlds is the ability to have your own 
                      place
                      The Lords of Empyria embraces this concept and while we continue to develop thisthere is 
                      plenty of room to place a purchased house 
                      and there are static houses to buy as well.</p>

                      <
                      center><a href="#" onclick="return bla(0)">Add-Ons</a> :: 
                              <
                      a href="#"onclick="return bla(1)">Buying Basics</a> :: 
                              <
                      a href="#"onclick="return bla(2)">Decorating</a> :: 
                              <
                      a href="#"onclick="return bla(3)">House Values</a> :: 
                              <
                      a href="#"onclick="return bla(4)">Mailboxes</a> :: 
                              <
                      a href="#"onclick="return bla(5)">Static Housing</a></center>
                      <
                      div id="txt" style="width: 60%; background-color: #CCCCCC;"></div></font>

                      </
                      body>
                      </
                      html
                      Now I only did the first link. Just to see if it would work. It didnt, anyone else care to see if I did something wrong, or maybe changed something that shouldnt have been changed...

                      Comment


                      • #12
                        Nope... Not a bright ideea. You said you want to keep your site as accesible as possible yet and less complicated. But if each innerHTML in layers ar so big, you will make this first page much to haeavier, hard to load, hard tu update....

                        The proper ideea, in my oppinion, is to use iframes.
                        KOR
                        Offshore programming
                        -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

                        Comment


                        • #13
                          Using iframes requires me to set up another page for the frame to read from. I dont want to make any more pages for my site.

                          All I want, is to be able to click the link, and text show describing that particular link.

                          Like in the code I posted for example: If you click on Add-ons, you get a description and prices for add-ons in the house.

                          You said you want to keep your site as accesible as possible yet and less complicated.
                          Actually, I believe I said that I didnt want to make 50 pages for my site.

                          Comment


                          • #14
                            When set the value to a variable, in javascript you have to get rid of all the "overwrapped" spaces, that means no overruled required empty spaces.

                            That means:

                            var bla = 'asdasd asdasd asdas<sda>sada';
                            is correct, while:

                            var bla = 'asdasd
                            asdasd
                            asdas
                            <sda>sada';
                            is wrong, as javascript take all the new line as a new code line.

                            You have

                            1. either write them without any wrong coding wrap

                            2. or add + for each new line string:
                            var bla = 'asdasd'+
                            +'asdasd'+
                            +'asdas'+
                            +'<sda>sada';

                            See now why I said that a long and intricate text layers means much more trouble than an easy iframe solution?

                            If you still want them on the same page, you will have to use dynamic change of CSS visibility or display. Know how to do that?
                            KOR
                            Offshore programming
                            -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

                            Comment


                            • #15
                              So for this:

                              PHP Code:
                              [0] = '<p>Once you place your house, you will want furniture and knick-knacks. 

                              About house addons: You can unlock them if you want to move them around, put where you want, 

                              and lock them down again (after theyve been placed).</p>'

                              It would need to be changed to something like this:

                              PHP Code:
                              [0] = '<p>Once you place your house, you will want furniture and knick-knacks.'+

                              +
                              'About house addons: You can unlock them if you want to move them around, put where you want,'

                              +
                              'and lock them down again (after theyve been placed).</p>'

                              Comment

                              Working...
                              X