Yeah, if the HTML isn't behaving, and you aren't running a web service, then javascript is your only recourse as far as I can see.