Dynamic Drop Downs

Posted on 2004-04-20
Last Modified: 2010-04-06
I currently have a perl program that produces a Email responds form.

Located on it is 3 drop downs, model type, model series, and model name.

When the user selects the model type the page reloads and the model series and model name drop downs are populated.

At this point the user can ether select their specific model name, or they can select a series. If they select a series the page reloads again and the model names list get small base on the series selection.

I really would like to get rid of the page reloading after each selection. I attempted to use Javascript to populate the menus. But the problem I ran into was that when the page went forward and then hit the back button. The Series and Model field were generally blank and I could not get it to repopulate with the data they previosu selected.

Can someone point me at a system that I can look at using that will allow me to make 3 dynamic drop downs, without page reloaded.
Question by:elmic
LVL 12

Expert Comment

ID: 10869857
you can do it two ways

inline frames or just frames (may not work in your case)
XMLHTTP to get the values using javascript and update the dropdowns..

Here is an example...
var objXML = new ActiveXObject("Microsoft.XMLHTTP");
var html;'GET','',false);
html = objXML.responseText
LVL 53

Expert Comment

ID: 10872560
The problem with dynamic content is that it is not part of the cached page, and the back button brings it back from the cache or reloads if there is no cache. I don't think using XMLHTTP will solve it because it is still populating dynamically and you are going to go back to teh original page when back is clicked.

To maintain state you would need to keep track of what was dynamically loaded on a cookie and then bring in the data from the cookie in the onload event.


Expert Comment

ID: 10876095
i have code that does that, but i dont think it will solve the back button problem as COBOL says, cookie or session would make sense to me.

also look at this
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Expert Comment

ID: 10895356
My solution to this would be to use wither the onBack() event, or onUnload (if onBack is not supported in your target browser).

Have something like this....

// in the header somewhere or onload
var firstTime = 1;

// have this in header
function checkBack() {
  if (firstTime = 1) {
    firstTime = 0;
    return false;
  } else {
     return true;

//in body tag

<body onUnload="checkBack();">

The main problem i guess with using onUnload (if onBack is not supported) is that the above code will try and stop you from going back and load the old form regardless of whether or not the user is going back - they might just be browsing to a different page. You could however check the target page and match that against the last history item i guess. Its up to you whether or not you need it.

It does also require that you have the original code to load in the back button. You could just save that in another variable when clicking on a series, then reload back again if the checkBack funtion is triggered.

I hope this helps.

LVL 53

Expert Comment

ID: 10899752
onback event??????

Where exactly could I find documentation on that event?  I can seem to find it with reference to any browser I have used, an none of my normal references seems to have anything on it.

As for the unload event you cannot re-load off of it, because that would override the user.  You may be able to get a popup open, but you are not going to force a reload. The user is leaving and built in security will prevent you from interferring.  If that was possible a web site could prevent you from ever leaving and you would have to re-boot to get out of such pages.


Author Comment

ID: 10931141
Doesn't seem to be a good answer to this problem. What I end up doing was using java to move the values to a second hidden form, clearing the first and then submitting the second. This wasn't the desire effect, but it fixed some of the problems I've been encountering.

I'm going to leave this question open a bit long in hopes someone else comes up with a soultion.
LVL 53

Expert Comment

ID: 12096898
Could we make it PAQ and refund please.  The thread has value even if we di not give the user a solution they could implement.


Author Comment

ID: 12128919
What's a PAQ ?
LVL 53

Expert Comment

ID: 12132803
PAQ: Previously Answered Question. It is what we call questions that have been closed and saved to the knowledgebase


Accepted Solution

Lunchy earned 0 total points
ID: 12138099
Closed, 250 points refunded.
Friendly Neighbourhood Community Support Admin

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to I "stripe" columns using XSLT 3 51
Snap images to the bottom of a div 5 67
two submit buttons one form 15 98
Adjust the position 3 65
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question