Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting rows and relinking with JS not working 1

Status
Not open for further replies.

sbressler

Technical User
Apr 12, 2004
3
US
Hello everyone - first time posting on the site. OK, well I have many issues with this calendar I'm trying to develop in javascript and I hoped that some of you might be able to help me.

The issue foremost is that it doesn't work in IE 6 or 7. Past that (in Firefox, in other words), I can only move one month before having to reload (backward or forward works), I'm guessing because when I append to the table using javascript, it doesn't really add the HTML so then when I try to delete later on it doesn't work this time (all in Firefox of course).

Is there a better way to do this or some minor fixes I can make to what I'm doing so that this all works? TIA!

-Scott
 
Why not build up the table as a large string and then set the innerHTML of a container to include the new layout that way? You have been able to use innerHTML across all browsers since 2000 - so it's not going to cause a problem.

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
I was considering doing that but what sort of container would I put the built-up code into? I also wonder if there are other restrictions of this method that I would encounter but can't think of now...
 
A div would do the trick. Give it an ID and you can set the innerHTML to be whatever you want (including the table you currently use).

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
But I don't want to remake the entire table is the thing, there is no reason to redo the header with the days of the week and everything -- though if it's just easier and better that way, then I suppose that could work...
 
Well... you can't use innerHTML on a table or a tr - so if you went down that route then you would have to deliver the whole table.

When you run some timings over the code to do that, it's going to show that it is faster to deliver the whole table as innerHTML to a div than it is to delete/create the rows and cells directly. At least that's my experience on doing this kind of thing in the past.

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top