OK do to my forum being an rp I am using the Additional Profile Options feature for role play stats, do to this it causes the mini-profile to stretch, and well I got the idea, why not add a toggle effect , so I did and I have came across one big problem...
The toggle effect work perfectly fine when you use it in the Profile page, but when you got to a thread and you go to use it it will only toggle for the very first person in that page of the thread as you can see here![]()
http://fmaworldsapart.vforums.co.uk/board/VideoGames/topic/2 21/action/view_topic/worst-gam es-of-2008#reply-9
Here is the javascript code I am using:
Code:
- <script>
- function swapRows(rowId){
- var persist = document.getElementById(rowId).style.display;
- for(i=0;i<arguments.length;i++)
- document.getElementById(arguments[i]).style.display = (persist=="none")?"block":"none";
- }
- </script>
And here is the code for the mini-profile:
Code:
- <center>
- <table width="115" id="mini_profile" cellpadding="0" cellspacing="0" border="1">
- <tr>
- <td class="window1" align="center">{display_name}</td>
- </tr>
- <tr>
- <td class="window1" align="center">
- <script>
- var a = /(Administrator|Super-Mod|Moderator|Guest Account)/;
- var rank = '<br />{rank_name}<br />';
- if(rank.match(a)){
- document.write('{rank_image}<br />');
- }else{
- document.write('{rank}<br />');
- }
- </script>
- {if:secondrygroup}{secondrygroup_image}<br />{/if:secondrygroup}
- </td>
- </tr>
- <tr>
- <td class="window1" align="center">
- <script type="text/javascript">
- assign_rank('{display_name}', '{posts}');
- </script>
- </td>
- </tr>
- {if:warning}
- <tr>
- <td class="window1" align="center">{warning}<br /></td>
- </tr>
- {/if:warning}
- {if:custom_title}
- <tr>
- <td class="window1" align="center">{custom_title}{/if:custom_title}</td>{ifnot:custom_title}<font color=#000000></font>
- </tr>
- {/ifnot:custom_title}
- </table>
- <br>
- <table width="115">
- <tr>
- <td align="center">
- {if:avatar}
- {avatar}
- {/if:avatar}
- {ifnot:avatar}
- <img src="http://i25.photobucket.com/albums/c51/dog199200/no-av.gif">
- {/ifnot:avatar}
- </td>
- </tr>
- <tr>
- <td align="center">{personal_text}</td>
- </tr>
- </table>
- <br>
- <table width="115" id="mini_profile" cellpadding="0" cellspacing="0" border="1">
- <tr>
- <td class="window1">Posts: {posts}</td>
- </tr>
- <tr>
- <td class="window1">
- {if:online}
- Status: <b><font color=blue>Online</font></b>
- {/if:online}
- {ifnot:online}
- Status: <font color=red>Offline</font>
- {/ifnot:online}
- </td>
- </tr>
- <tr>
- <td class="window1">
- {if:gender}Gender: {gender}{/if:gender}
- </td>
- </tr>
- <tr>
- <td>
- <span style="float: left;">
- Rep: {reputation}
- </span>
- <span style="float: right;">
- {if:reputation_give}
- <font size=1>Give -</font>
- {/if:reputation_give}
- {if:reputation_take}
- <font size=1> Take</font>
- {/if:reputation_take}
- </span>
- </td>
- </tr>
- </table><br />
- <table width="115" cellpadding="0" cellspacing="0" border="1">
- <th onClick="swapRows('data1');return true" class="title1">~ Forum Data ~</th>
- <tr>
- <td class="window1" ID="data1" align="center">
- {additional_info}
- </td>
- </tr>
- </table>
- <br />
- {contact}
- <br />
- <script>
- var a = '{display_name}';
- var x = (a.match(/view_profile\/user\/(.+?)(\/|"|\/")/))?RegExp.$1 : '';
- if(x != vf_username){
- document.write('<a href="/action/add_buddy/user/'+x+'">Add to Buddies</a>');
- }
- </script>
- </center>
Now with all the information is, can someone please help me fix the code so that it will work per person, as well can you make it so that the table starts up instead of down, so they gave to click to display the stats.
bump
An ID is an attribute that must be different for each element it is attached to. The reason it's only working for the first instance of "data1" is because ID's are only meant to be attached to one element.
To get this to work you'll need to change the ID's to classes, loop through all the TD's, find the ones with the class you're searching for, and change the visibility for all of them.![]()
OK i'll do that last, first I want to fix a small problem
Updated Table Code With Toggle:
Code:
- <table width="115" cellpadding="0" cellspacing="0" border="1">
- <tr colspan"1" align="center">
- <td onClick="swapRows('data1');" class="title1">~ Forum Data ~</td>
- </tr>
- <tr ID="data1" colspan"2">
- <td class="window1" align="center">
- {additional_info}
- </td>
- </tr>
- </table>
I edited that from the code above and i got it a little bit closer, but now I get this:
![]()
Seems as if the cell doesnt span over enough, but I have tried to fix it and yet nothing helps that, I want to get that fixed before I edit the JS file and it ends up making things worse![]()
havnt tested this but try
GLOBAL hEADDER
Code:
- <style>
- .mp_hide {
- display:none;
- }
- </style>
- <script>
- function moo(s){
- if(s.parentNode.nextSibling.className == 'mp_show'){
- s.parentNode.nextSibling.className = 'mp_hide'
- } else {
- s.parentNode.nextSibling.className = 'mp_show';
- }
- }
- </script>
MP template
Code:
- <table width="115" border="1" cellpadding="0" cellspacing="0">
- <tbody>
- <tr>
- <th onclick="moo(this);">~ Forum Data ~</th>
- </tr>
- <tr class='mp_show'>
- <td class="window1" id="data1" align="center">
- Level: 8.3
- <br>Money: 438
- <br>Jobs Done: 0
- <br>Contests Won: 0</td>
- </tr>
- </tbody>
- </table>
eidt: just to stop strethcing ^^
It works, and I recognize that code, quick and simple, dont wnat to code it so revert to proboards and convert right
Well thank you
ermm...no its not from PB, i just wrote it up in while on firebug on your forum. there was no such codeits just common JS knowledge ^^
Notice i just used moo()![]()
i've seen this before:
# if(s.parentNode.nextSibling.className == 'mp_show'){
# s.parentNode.nextSibling.className = 'mp_hide' } else { s.parentNode.nextSibling.className = 'mp_show';
# }
I just don't know where, maybe something you could of coded for proboards, possibly your mini-profile background mod
must be just the name mp_hide and mp_show or somethingits the way i name Miniprofile classes XD