I'm trying to use javascript to code up a dynamic form, where elements are shown or hidden based on whether or not checkboxes are selected.
For the most part, it works okay. I defined methods that read the value of the checkbox, and rearrange the page accordingly, and then set them to the checkboxes' onclick methods. I then also set them up to run on document loading once so that the page renders correctly on refresh by the user, with code like this Event.observe(window, 'load', manageCheckbox1);
(this uses the Prototype library to set it to run on loading; I'm not really sure why this is better than just a raw call to the function placed in the html after all relevant elements but this is how I've seen others do it).
However, the trouble with this approach is that the page is visible for a split second on load before the javascript is run, and then all the elements jump as the javascript inserts or removes elements.
Is there a better way to do this to avoid that unpleasant jumping effect?