View Full Version : Enable/disable DDMs?

08-10-2005, 02:47 PM
I have a few pages as part of a site which share a similar feature: they all have a series of DDMs (drop down menus, aka <select>, typically 2 - 4 per page but this varies), each accompanyed by a radio box. The user selected the radio boxd that corresponds to the DDM that is relevent to them and they then select from that DDM their option. What I want to do is to disable the other DDMs, those connected to none-selected radioboxes, so they are greyed out. Now, I've got this working but it's got a few icky side effects. Here's what I did:

1) I set the backend perl to set a JS variable to the preselected menu, ie. what this page's settings originally were.

2) I build an array of the DDMs (again with a lot of help from backend Perl to figure out exactly what DDMs are needed for this particular scenario, no problem here).

3) Near the end of the HTML, I have a bit of JS that sets up the initial enable/disable status of the DDMs.

4) onChange of a radio box, I go through the DDMs and enable/disable as required.

Now, this is all good as it appears, but there is a problem. If the user changes their option (ie. selects a different DDM), saves their change by submitting the form and then changes their mind and hits Back, the selected DDM and the enabled DDM are no longer synchonized. The browser (all modern browsers) remember the form status and the selected radiobox. However, #3 then kicks in and the javascript enables the original DDM, not the new selection.

I solved this by storing the selected DDM in a cookie and then when the page is loaded, this cookie is checked for - if found, it loads the cookie value and deletes the cookie, otherwise it loads the Perl generated default. The short answer is that this sucks. A lot. Long answer: when the cookie is deleted, further reloading will sufer the original problem. If it's not deleted, the cookie affacts other data, such as when a different object is loaded on this page. This also happens, albeit less so, with cookie deletion, as they might not go back so the deletion never occurs.

I feel my solution to the Back problem is a bit nasty so idealy, I'd like a way to fix this (asking the user to hit Ctrl-F5 isn't an option, although it does solve the problem as it reloads from the server and perl sets the new default). If my solution is the best there is, can this be fixed? Can Ctrl-F5 be simulated?

08-10-2005, 03:09 PM
If you use .net web forms, form state is saved via a rather complicated mechanism that uses a hidden form field, but it addresses all these issues. You may want to look into how they do that and try to duplicate it with the technology you are using.

As to control+F5 being simulated, yes, location.reload(true) will reload from the sever, but other issues will crop up (how to know when to do it, endless loop issues, etc).

08-10-2005, 03:12 PM
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0

... will this do it?! I can send these through Perl no problem.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum