Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Enable/disable DDMs?

    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?

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    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).

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •