1 Attachment(s)
Instantly update bottom frame when user changes menu selections in top frame
Hello,
This is an excellent website, and I'm hoping someone here can help me create what I need. I myself do not know any javascript or any other web programming language, but I have some programming experience, so I can usually "read" code if I understand what it's trying to do.
Okay, here's what I'm looking for:
Imagine a frameset with a top frame containing multiple dropdown menus, and a bottom frame that will load a specific page determined by the user's selections in the top frame. Every time the user changes something in the top frame, I want the bottom frame to be immediately updated with the correct page (no clicking of "submit" required). The pages to be displayed in the bottom frame already exist, and their filepaths and filenames are simple combinations of the selected menu values.
The menus are non-hierarchical. The values available in any given dropdown menu are independent of the values selected in other menus. (So, it is NOT like searching on cars.com, where you select a make, then select a model. In my system, you ARE be able to choose a Ford Impala, for example :) ).
The dropdown menus in the top frame should also have prev/next arrows that the user can click to quickly cycle through the available values.
---------------------------------------------
EXAMPLE:
Say I'm looking at farm output data, broken down by the following categories:
STATE: AZ, CA, NM
CROP: Corn, Rice, Wheat
Month: Jan-Dec
Measurement: Bushels, Tons, Dollars
The top frame of my frameset will have dropdown menus for each of these 4 categories (State, crop, month, and measurement).
For each unique combination of the 4 categories, I have a specific web page that I want to display in the bottom frame of the frameset. The path and filename of each page is a direct function of the selected values (e.g. the AZ November Corn Tonnage page might be AZ/NOV/CORN/TONS/AZ_NOV_CORN_TONS.HTM).
I've attached a simple picture of what I'd like the menu to look like.
---------------------------------------------
Like I said earlier, I'm no web programmer, but I think the script will work something like this:
1. User changes a value of a menu item.
2. The displayed value in the menu is changed to show the newly selected value.
3. A string is generated that is a concatenation of the selected values of all the menus. This string is the path and filename of the page to be loaded in the bottom frame.
4. The bottom frame is loaded with the file whose name was formed in the previous step.
Is there anyone who can give me pointers or write some basic code for accomplishing what I'm describing? Any help you can provide would be greatly appreciated! Thanks!
JIM
Eureka! Now on to the next item..
Good news! My only problem in my code was that I did not have any values assigned to my menu choices, just labels. Simply adding value="bla" to the dropdown menu options fixed my problem. I tested the loading of the bottom frame and everything.
Before:
Code:
<option selected>BLONDE</option>
<option>BRUNETTE</option>
<option>REDHEAD</option>
</select>
After:
Code:
<option value="BLONDE" selected>BLONDE</option>
<option value="BRUNETTE">BRUNETTE</option>
<option value="BRUNETTE">REDHEAD</option>
</select>
That fixed it!
The next thing I need to add are previous/next buttons to place to the left and right of each dropdown menu. When a user clicks on, say, the "PREVIOUS" button, the value in the dropdown menu will change the value immediately above it in the list. If already at the first value, then the value will change to the last value (e.g., say the drop down list contains the letters of the alphabet, in order, and the starting value is "B". If the user clicks "PREVIOUS" onces, the value will change to "A", and if he clicks it again, it will change to "Z").
So far, I only have the comments written for this function:
Code:
// When clicked, it decrements the selected item of the specified menu
// selectedlist is a dropdown menu
function decrement(selectedlist)
{
// Determine how many items are in selectedlist (so we know highest index number)
// CHANGE THE SELECTED ITEM:
// if current index is 0, then new index is max index
// else, new index is current index - 1
// set the value of menu to the value corresponding to the new index
// run buildStringandLoadFrame(), unless an onChange event is auto-generated
return true;
}
I'll see if this one gives me any trouble. I guess I need to learn how to get the number of entries in a dropdown list, and I need to learn how to change which item is selected.
JIM