PDA

View Full Version : help with something completely unrelated



Rob Oplawar
April 3rd, 2007, 11:52 AM
I'm asking here instead of on some scripting tutorial site because I know people here and know I can expect a reply sooner or later. If anybody here is fluent in PHP, Javascript, and/or HTML, please help me out here.

I'm working on a webpage that displays a usable timesheet for employees. The page is a PHP script that accesses a database to nab all of an employee's entered hours per day, then puts them into a table of divs (see below) and when an employee has no hours entered for a day, it puts in a 0.

The format of the cells is as follows:
<td><a onclick='replace("1-0");' class='hour_number' title='Click to enter the number of hours.'><div class='weekday' id='1-0'>0</div></a></td>

Employees can enter their hours based on which area they worked in on that day, hence the 2 dimensional reference to each cell.

The javascript replace() function I implimented uses <divid>.innerHTML to change a cells contents to the new number of hours.

replace() calls total() after changing the value to add the entered value to various daily/weekly/monthly total cells. total() also uses .innerHTML to grab the values of cells in a row or column to add them up. I do this instead of using variables to store values because if I did that I'd have something like a 100x20 array stored on the client side, and I want this script to go easy on the client side computer.

The php script dynamically generates the cells so the user can, for example, set the number of days to be displayed. The total() function is called in the body onLoad.

OK, here's my problem: alas, Mozilla has failed me, and gets confused when reading the innerHTML of cells. I downloaded Firebug (a nice firefox debugging plugin) and here's what it reports to me:
The source code shows the layout like this: <td><a><div>#</div></a></td>

Most of the cells get properly parsed heirarchy:
<td>
<a>
<div>0</div>
</a>
</td>
but some of them, completely at random (goddammit!) end up with something like
<td>
<a/>
<div>
<a>#</a>
</div>
<a/>
</td>
and as a result, it can't properly get the values out of the cells, and the a's point to nothing, so the div doesn't have the replace() function onClick anymore.
The worst part is I only get this error in Firefox.
WTF?! Is anyone familiar with this bug? can you help me out?

Edit: here's a screenshot of what Firebug is reporting, but keep in mind that when I view source it still looks like the code snippet above.
http://spacebrick.net/pictures/blog_gallery/firefox_bug.jpg

Rob Oplawar
April 3rd, 2007, 06:21 PM
sorry for double posting, but... anyone? anyone? beuler? beuler?