TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 09-26-2007, 10:49 PM   #1 (permalink)
The Acquainted
Upcoming Programmer 
 
CMellor's Avatar
 
Join Date: Sep 2007
Location: Leeds, UK
Posts: 141
Thanks: 6
CMellor is on a distinguished road
Default Change Table Row Colour with Checkbox onClick

Hello,

I think this may be a really simple task, but I'm no Javascript guru, so I'm having trouble grasping it. Google also wasn't much help, but probably because couldn't describe well enough what I wanted.

Before I start, if anybody does reply and uses PrototypeJS, I also use it and a method using it would be much more preferred, but if not, normal Javascript will do.

So I have this table set up... I'm not much of a table user, but using div's for this would just be too much hassle.

Code:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      <th align="left" colspan="2">Message</th>
      <th width="25%">Sender</th>
      <th width="10%">Mark</th>
    </tr>
  </thead>
  {foreach item=pmsg from=$pmno}
  <tbody>
    <tr id="tr" class="{if $pmsg.is_new eq 1}is_new{else}{cycle values="color1, color2"}{/if}">
      <td align="center" width="5%">
      {if $pmsg.is_new eq 1}
      <img src="images/new_pm_folder.png" alt="New PM" title="New PM" />
      {else}
      <img src="images/no_new_pm_folder.png" title="No new PM" alt="No new PM" />
      {/if}
      </td>
      <td><a href="ucpanel/pm/{$pmsg.pm_id}/">{$pmsg.subject}</a><div class="pm_date">{$pmsg.date|date_pretty}</div></td>
      <td align="center"><a href="user/{$pmsg.username|urlencode}/">{$pmsg.username}</a></td>
      <td align="center"><input name="pm_option[]" type="checkbox" id="pm_option" value="{$pmsg.pm_id}" /></td>
    </tr>
  </tbody>
  {/foreach}
</table>
The code between {} is from Smarty.

All I want to do, is when the checkbox is checked, I want the table row to change a different colour, and when unchecked, it will remove the colour... sounds simple huh? but I couldn't work my head around it... I mean I tried for ages and almost got it; I managed to change the colour of it, but when unchecked, it didn't remove it.

Thanks for any help.
__________________
Not quite a n00b...
CMellor is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:46 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design