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

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.

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.


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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now