![]() |
Help needed to show hide table rows
Hi
Fairly new to this and am having a problem combining javascript with php. I have a basic database table set up as in the picture below. http://img246.imagevenue.com/loc356/..._122_356lo.JPG I wanted to click the show and hide buttons in order to show/hide all the information below the top row for each record. I thought if I gave all the rows the same id the code I had would do this but it only hides the first of the rows (as in the picture below). http://img194.imagevenue.com/loc448/..._122_448lo.JPG the code I am using is Code:
<html>Any help would be greatly appreciated, and could salvage what is left of Christmas!!!!! |
IDs must be *UNIQUE* on a page. When you use the same ID more than once, then some browsers will find the first one and some just won't find it.
You could use the same *basic* ID but then append a suffix, say "A","B","C","D". But there are more clever ways that would avoid ids altogether. |
By the way the <font> tag is way way way obsolete.
Learn to use CSS classes instead! Here's a demo of what you COULD do. Notice that it doesn't care how many detail lines there are per header line. Notice there are no <font> tags. Notice that the JS code is "unobtrusive" and depends only on the id of the table and the class name "header" for header rows. Code:
<!DOCTYPE html> |
By the by, a comment on you PHP/SQL code.
Code:
$query="SELECT * FROM staffinformation WHERE Team= 'Juventus'";It may be working now, but it's very very poor database practice to depend on it working forever. |
Many thanks for the help Old Pedant (and the advice) I think I have been running before walking properly and need to go back over things like CSS. The code on hiding the rows is great but I can't get it to work when generating the rows from a database, it only works for the top row. Is there a way to adapt this or will this method only work for a set table?
|
| All times are GMT +1. The time now is 09:10 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.