PDA

View Full Version : vBa alternate <td> background color (Javascript)


DFORMS
09-26-2012, 03:35 PM
Hi,

I'm currently running a phpBB forum (http://fragnet.ca/forum) and this is my index page (http://fragnet.ca). Recently I've been feeling limited and now I want to move to VB4. I've set up a VB test board with vBa as my index page (http://quebec-gamer.ca http://quebec-gamer.ca/forum). I want to have alternate background colors for some of my <td> on my index page. This is what it looks like on my current site:

http://quebec-gamer.ca/images/color_exemple.jpg

On my phpBB portal index page I have the following Javascript in my head tag:

<script type="text/javascript">
function alternate(id){
if(document.getElementsByTagName){
var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr");
for(i = 0; i < rows.length; i++){
if(i % 2 == 0){
rows[i].className = "even";
}
else
{
rows[i].className = "odd";
}
}
}
}
</script>


and the onload in my body tag:

onload="alternate('thetable');"


The tables are then tagged with id="thetable" and it works on my current website but I can't get it working on my vBa page. I tried adding the Javascript to the header template then the onload to the body tagged in the forumhome template and adding id="thetable" to the table tag in the adv_portal_module_wrapper but it's not working.

Any help with this would be greatly appreciated.

Thank you!

--------------- Added 1348759193 at 1348759193 ---------------

I am willing to pay for help.

--------------- Added 1348762620 at 1348762620 ---------------

OK, I found this simplified jquery version:

<script src="jquery.js"></script>

<script>
$(document).ready(function()
{
//for table row
$("#alternate:even").css("background-color", "#000000");
$("#alternate:odd").css("background-color", "#ff0000");
});
</script>

and I got it to affect some parts of my site but it has zero effect on the vBa recent threads module : s !?

I added the id="alternate" to the <tr> tag but it doesn't work:

<tr id="alternate" class="vba_module" style="border-right: 0; border-left: 0;">
<td class="blockrow" valign="top">
<vb:if condition="$mod_options['portal_threads_newpostarrow'] AND $show['gotonewpost']">
<a href="{vb:raw vboptions.bburl}/{vb:link thread, {vb:raw thread}, {vb:raw pageinfo_newpost}}"><img alt="{vb:rawphrase go_to_first_new_post}" src="{vb:stylevar imgdir_button}/firstnew.png" border="0" class="inlineimg" /></a>
</vb:if>
{vb:raw thread.prefix}
<a href="{vb:raw vboptions.bburl}/{vb:link thread, {vb:raw thread}}" title="{vb:raw thread.preview}"<vb:if condition="$show['gotonewpost']"> style="font-weight: bold"</vb:if>><span style="font-weight: bold">{vb:raw thread.title}</span></a>

<vb:if condition="$thread['rating']">
<br/>
<img src="{vb:stylevar imgdir_rating}/rating-trans-15_{vb:raw thread.rating}.png" alt="" />
</vb:if>

<vb:if condition="$mod_options['portal_threads_multipage'] AND $show['pagenav']">
<br/>
(<img class="inlineimg" src="{vb:stylevar imgdir_misc}/multipage.gif" border="0" alt="" /> {vb:raw thread.pagenav}<vb:if condition="$show['pagenavmore']">... <a href="{vb:raw vboptions.bburl}/{vb:raw thread.lastpagelink}">{vb:rawphrase last_page}</a></vb:if>)
</vb:if>

<vb:if condition="$show['lastpost']">
<br/>
{vb:raw thread.lastpostdate} <span class="time">{vb:raw thread.lastposttime}</span><br />
</vb:if>

<vb:if condition="$mod_options['portal_threads_threadstarter']">
<div>
<vb:if condition="$thread['postuserid']">
{vb:rawphrase by_x, {vb:link member, {vb:raw thread}, null, 'postuserid', 'postusername'}, {vb:raw thread.postusername}}
<vb:else />
{vb:rawphrase by} {vb:raw thread.postusername}
</vb:if>
</div>
</vb:if>
</td>


<vb:if condition="$mod_options['portal_threads_replies']">
<td align="center" class="blockrow">
{vb:raw thread.replycount}
</td>
</vb:if>

<vb:if condition="$mod_options['portal_threads_views']">
<td align="center" class="blockrow">
{vb:raw thread.views}
</td>
</vb:if>

<vb:if condition="$mod_options['portal_threads_showforum']">
<td class="blockrow" align="right">
<a href="{vb:raw vboptions.bburl}/{vb:link forum, {vb:raw thread}, null, 'forumid', 'forumtitle'}"><img src="images/statusicon/forum_{vb:raw thread.forumid}/forum_new-48.png" /></a>

</td>
</vb:if>
</tr>

Again I am very willing to pay via Paypal for support.

Thank you!