Set a td class on the fly... easy???

N

news.west.cox.net

I have td(s) set up like this

<td id="1">Blah</td>
<td id="2">Blah blah</td>
etc...

Then in my script I am trying to do this...
for(var k = 0; k < tdArr.length; k++) {
if (something) {
tdArr[k].class = "myH2"
}
}

But this does not set the class for the td cell...

The javascript console says the error is:
"missing name after . operator"

What am I doing wrong? Can a class be assigned to a td like this?

Thanks
 
R

RobG

news.west.cox.net wrote:
[...]
I think I am finally done with the javascript for this page.

http://pending.buildingonline.com/spib/locator.pl

Hmm, not a bad looking page, can I offer a couple of tips?

I'm at a bit of a loss as to why you made display of the header image
dependent on JavaScript. It may be better to load an image with an
HTML <img...> tag then change it with JS. That way the page still
looks good without JS, just that the image won't change.

Another trick would be to hide the "Check All" checkbox - say use
style="visibility: hidden;" so your page layout is unaffected - then
use JS to reveal it when the page is loaded;

checkboxRef.style.visibility = 'visible';

That way if the user doesn't have JS enabled, they don't see a button
that doesn't do anything for them.

I also don't know why the "View entire roster in popup" page uses JS at
all. On the ancient machine I'm using, it loads in about 1/4 the time
with JS disabled and looks pretty much the same. I can't see how JS is
improving the page.

Anyhow, what you do about the above is up to you :)

Cheers, Rob.
 
N

news.west.cox.net

RobG said:
news.west.cox.net wrote:
[...]
I think I am finally done with the javascript for this page.

http://pending.buildingonline.com/spib/locator.pl

Hmm, not a bad looking page, can I offer a couple of tips?

I'm at a bit of a loss as to why you made display of the header image
dependent on JavaScript. It may be better to load an image with an
HTML <img...> tag then change it with JS. That way the page still
looks good without JS, just that the image won't change.

Another trick would be to hide the "Check All" checkbox - say use
style="visibility: hidden;" so your page layout is unaffected - then
use JS to reveal it when the page is loaded;

checkboxRef.style.visibility = 'visible';

That way if the user doesn't have JS enabled, they don't see a button
that doesn't do anything for them.

I also don't know why the "View entire roster in popup" page uses JS at
all. On the ancient machine I'm using, it loads in about 1/4 the time
with JS disabled and looks pretty much the same. I can't see how JS is
improving the page.

Anyhow, what you do about the above is up to you :)

Thanks for the tips. The big JS trick I am doing is disabling checkboxes
depending on what state has been selected. For example, click on Texas,
Florida, or Alababama and some of the boxes become useless.

This is a perl script so all of the javascript (well most of it) is created
on
the fly. Nothing related to the database is hardcoded... which will make
life much easier in the coming months and years.

Thanks again for the tips and the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top