PDA

View Full Version : frames and updating form combobox objects


raoul
12-18-2002, 10:36 AM
Hi,

I have a page with 2 comboboxes. The items of combobox 2 depend on the selected item of combobox 1. Because there are over 50 options and each of them have over 30 options I decided to use a framed page and have the options for combox 2 loaded dynamically through an invisible page. When the form is submitted the next page opens at the top location (not in framed page!).

This all works fine. The problem is that when the user clicks the back button on the next page he will get errors. What happens is that the invisible page is trying to update combobox 2 while this part of the mainpage is not yet loaded (error message: top.mainpage.form1.cities is null or not an object).

I tried to put this part of the script in the invisible page in an if-condition:


if(top.mainpage.form1.cities ){

// code to update the combobox on the mainpage

}


but this has no effect, I still get the message?

Anyone knows how to fix this

Thanks,
Raoul

glenngv
12-18-2002, 10:38 AM
you'd be better off using this double-combo (http://www.javascriptkit.com/script/cut183.shtml) script.

raoul
12-18-2002, 11:47 AM
Thanks,

It is this sort of code what I am using but because of the large number of total possible options (well over 2000), I think it is a good idea not to load them all at once into the page but dynamically from a database.

Although I still don't understand how to fix the problem I found an 'ugly' solution by simply doing a window.location="blank.htm" at the end of the invisible page. This way the browser loads the blank page when the back button is pressed.

raoul

glenngv
12-18-2002, 11:55 AM
But after the page has loaded, dynamically changing the options in combo box 2 is much faster than your solution.

raoul
12-18-2002, 10:56 PM
yes, I thought that would be a problem that's why I tested it first on one option and it turned out that it takes about 1 sec to update combo box 2. I think it is fast enough as at the time I moved the mouse to combobox 2 it already was updated. And, as this is for a search engine, this solution also makes it pretty easy to instantly show the number of search results for the specific option.