|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
#1 |
|
Member (5 bit)
Join Date: Mar 2002
Posts: 26
|
Using Javascript to create alternating rows in a table
Hello,I'm trying to loop through a table and set a different style for every other row. I can't seem to make it work. The code below highlights every row the same color based on the number of rows entered (i.e. Rows variable). Any ideas?
PHP Code:
Last edited by Statica; 01-24-2005 at 06:27 PM. Reason: Added code tags |
|
|
|
|
|
#2 |
|
Moderator
Staff
Premium Member
Join Date: Aug 2003
Location: Richmond, VA
Posts: 7,835
|
Can you edit your post to put the entire code within the [ php ] [/ php ] brackets (without spaces)?
kram
__________________
"For today, goodbye. For tomorrow, good luck. And forever, Go Blue!"
University of Michigan President Mary Sue Coleman |
|
|
|
|
|
#3 | |
|
Member (5 bit)
Join Date: Mar 2002
Posts: 26
|
Code for alternate rows
Quote:
PHP Code:
|
|
|
|
|
|
|
#4 |
|
Member (5 bit)
Join Date: Mar 2002
Posts: 26
|
alternate table rows using javascript
I posted my issue last week but the code wasn't displaying correctly because I didn't use the php tags. I'm posting it again because I haven't heard anything. I'm trying to alternate the row colors of every other table row by looping through the number of rows entered by the user. The code I created below highlights all the rows one color, depending on the number I enter. Any ideas?
PHP Code:
|
|
|
|
|
|
#5 |
|
Member (8 bit)
Join Date: Aug 2002
Posts: 246
|
dont repost on a question you already made a thread for.
That said, enlighten us with what the DataForm object is and what are you trying to extract out of it? Looks like your Rows variable is trying to get the # of rows? Also, how are you outputting your HTML? are you doing document.write(begRow)? Theres no point putting your loop because you're overwriting the begRow variable over and over again. The rest of your code's necessary... |
|
|
|
|
|
#6 |
|
Premium Member
Join Date: Jun 1999
Posts: 9,231
|
Threads merged.
|
|
|
|
|
|
#7 |
|
Member (5 bit)
Join Date: Mar 2002
Posts: 26
|
I'm actually trying to create a table component in Dreamweaver. I created the DataForm object in html so the user can input the number of rows and colums to create a table. I also want to give the functionality of alternating rows. I created an .html file and a .js file and I reference the .js file within the .html as shown below.
PHP Code:
PHP Code:
|
|
|
|
|
|
#8 |
|
Member (8 bit)
Join Date: Aug 2002
Posts: 246
|
Here I did the work for you... I dont use any kinda automatic editor because they're crap. EditPlus is better than Notepad because it highlights tags and stuff for you tho.
Anyways... just tag this at the bottom of your HTML page before the /BODY tag. Or put it in a function in a external file and call it at the end, or whatever etc... etc... PHP Code:
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|