Note: The PDF has NOTHING to do with this. I am not parsing the PDF or
using it at all, it is only being used to show what the actual ballot
looks like.
The data in the PDF is already in a database and I am trying to create
an HTML table to mimic the one on the sub.htm page based on the data
from the database tables.
I am returning the data from a database in separate arrays, i.e.
PRESIDENT
CONGRESSIONAL
COUNTY
NONPARTISON
AMENDMENTS
The crux of the problem is when to break columns in the table. I am
struggling mightily with this. It really depends on the number of
elections and candidates for the first table. However, the amendments
table is going to be difficult because you can’t just count the number
of rows based on entries in the database table.
Figuring how to break the columns has really got me stumped. I thought
I’d be able to calculate the “lines” and build a table where the columns
break where I want but when I began looking at how the amendments text
flowed, it proved too difficult to use that method.
I don’t think I’ve ever seen an “algorithm” to work this kind of thing
with HTML tables.
I would copy and paste the HTML for the example and replace the static text with dynamic text. Seems like the HTML there is doing exactly what you need so why change it? Then again I’m under the impression that this is a one time thing. Where the info the database is only there to calculate poll results for this ballot? Another ballot for 2011 would require a newly developed solution or is the idea to reuse the same code for every year/ballot but change the data?
Also is there any particular reason for the layout? It would be be much simpler and straightforward to use a traditional question and answer list – no? On the web you won’t run into page issues like you would with printing everything as list so a list seems more appropriate than that contrived table layout? Seems stupid to mimic the print the layout. If you could sway the client in the other direction that seems like the best solution – perhaps you’ve tried? Either way though, I would use the HTML in the example to make life simple.
This will be used in several different localities so it has to be dynamic. Each election will have different number of “entries” so I have no way of knowing, beforehand, how “tall” the table needs to be. I can use templates for each race but, again, I don’t know how many there will be. And then, again, there are the amendments, the text for each of those is variable so determining the layout for those is doubly-difficult.
The visitors will not be actually making selections on the ballot, this is for presentation purposes only. Believe me, I have tweaked this much more than it was when I originally got it from the customer. You should have seen how crappy the markup was. I, too, feel it is kind of stupid to mimic it as well, in fact, I asked them why they just didn’t present the PDF ballot(s) and got no answer.