...

View Full Version : Ok to do this? put an onclick in a TR



JimM
02-15-2008, 10:05 PM
Just wanted to check to make sure this practice is ok prior to heading down the road with this code. It validates but is it ok to put an onclick in a TR tag.



<table class="listview" width="700">
<tr><td colspan="4" class="msgblock"><?php echo $var_message; ?></td></tr>
<tr class="listheader">
<th>Last Name</th>
<th>First Name</th>
<th>E-Mail</th>
<th>Phone</th>
</tr>
<?php if ($loop > 0) { for ($i=0; $i<$loop; $i++) { ?>
<tr class="<?php echo ($i % 2) ? 'listRow0' : 'listRow1'; ?>" onclick="window.location='<?php echo $_SERVER['PHP_SELF'] ?>?action=Display&amp;id=<?php echo $data_all[$i]['ID'] ?>'">
<td><?php echo $data_all[$i]['last_name'] ?></td>
<td><?php echo $data_all[$i]['first_name'] ?></td>
<td><?php echo $data_all[$i]['email_add'] ?></td>
<td><?php echo $data_all[$i]['phone'] ?></td>
</tr>
<?php } } ?>
</table>

kosstr12
02-16-2008, 02:37 AM
I'm almost positive it is, I've seen it done with javascript, don't why you cant with PHP

VIPStephan
02-16-2008, 02:55 AM
This has nothing to do with PHP, and even if it would be written through PHP the output is still JS. And yes, you can do that. I don’t see any reason why you shouldn’t. As long as an element belongs to the DOM you can manipulate it with JS.

kosstr12
02-16-2008, 03:46 AM
How does this have nothing to do with php?

bazz
02-16-2008, 11:31 PM
because, I think, the issue is about (x)html coding rather than how it is sent to the browser. The output (source view) only shows the finished html which is where any issue about the <tr> would be evident.

bazz



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum