Forums

window onload

blindman 14 Sep, 2009
I have a long form that hides and displays sections at a time using script. The scriptcode that makes this happen is shown below. Since the upgrade, the entire form shows, so apparently window.onload isn't working. Is there another way to hide all sections except the first one when the form first loads?

Thanks.

// collapse individual elements
function collapseElem(obj)
{
var el = document.getElementById(obj);
el.style.display = 'none';
}
// expand next element
function expandElem(obj)
{
var el = document.getElementById(obj);
el.style.display = '';
}
// collapse all elements, except the first one
function collapseAll()
{
// change the following line to reflect the number of pages
var numFormPages = 21;

for(i=9; i <= numFormPages; i++)
{
currPageId = ('mainForm_' + i);
collapseElem(currPageId);
}
}
// run the collapseAll function on page load
window.onload = collapseAll;
GreyHead 14 Sep, 2009
Hi blindman,

Since which upgrade?

If the whole form is showing then there's probably a JavaScript error somewhere on the page. Can you post a link?

Bob
GreyHead 15 Sep, 2009
Hi blindman,

There is no much script on the page that it's close to impossible to see what is happening.

You have two versions of MooTools loading and at least one of JQuery (the two usually conflict unless you adapt the JQuery code).

If I load the form without the template then the collapse works - but all the elements are collapsed and you only see the CF strap-line which suggests that something is broken there too.

If I edit the html to display the first block all is well but I get a JavaScript error when I click continue.

collapseElrm is not defined
function onclick(event) { collapseElrm("mainForm_9"); expandElem("mainForm_10"); }(click clientX=1247, clientY=89)

I think that's probably a typo for collapseElem.

I suggest that you debug first without the template, and when that is working OK add the template again and see if there are any JQuery conflicts.

Bob
This topic is locked and no more replies can be posted.