PDA

View Full Version : Using the Triple Combo Box in Tandem w/Frames


soyal
10-23-2002, 08:54 PM
Hi...

I'm using the script found at the URL below (although highly customized w/my own info.):

http://javascriptkit.com/script/script2/triplecombo.shtml

After the user selects a value from the last dropdown box, he/she is automatically swept away to the URL specified in the code (which takes into account each of the three choices the user has made). I guess I can deal with not having a button to press. BUT--what I'd really like is to have the dropdown boxes remain in the viewer's sight at all times (an easy way for them to remember what choices they made). I figured this would be good use for a frame. However, no matter what I do, I can't get the URLs to open anywhere other than in the frame where the dropdown boxes are (which then totally obstructs the view). Anyone have any ideas?


soyal

smeagol
10-23-2002, 10:14 PM
When you select an item in the last Listbox, you execute the function "redirect2()". Inside redirect2() there is only one line of code that says:

window.location=temp1[z].value;

If your triple combobox script is in one page of a frame, and you want the combobox to open in another frame, all you must do is change the line to the following:

parent.mainFrame.location=temp1[z].value;

You'll need to change the part that says mainFrame to the name of the frame you want to open your page into.

If you would like to use a button instead of having the page automatically open when you select the item in the last combobox, let me know and I'll show you the code for that, too.

Hope this helps.

soyal
10-24-2002, 01:51 PM
Thank you SO much, smeagol! That worked beautifully (I guess I still have a lot to learn)! I appreciate your help!!

And I'll take you up on your offer to assist with the button instead of the immediate redirection that the script currently provides <g>.

Again, thank you!

smeagol
10-24-2002, 02:20 PM
No problem soyal. I'm glad I could help.

Here's how to do the button:

Remove the onchange event handler from the last combobox. It should look like this after the removal:

<select name="stage3" size="1">

Next, put a button immediately after the last combobox like so:

<input type="button" value="Go" onclick="redirect2(document.isc.stage3.options.selectedIndex)">

Change the redirect2() function so that it will catch an invalid value in the stage3 combobox. Here's the code for redirect2():

function redirect2(z){
if(document.isc.stage3.value == ' ')
;// Do Nothing. The user didn't choose an item in Stage3.
else
parent.mainFrame.location=temp1[z].value;
}

That should do it. Now the button will redirect you when you click it instead of the last combobox.

soyal
10-24-2002, 02:35 PM
FANTASTIC! You are so articulate! Again, your instructions worked beautifully. If you are not already in the field of education, I hope that you will at least consider it.

I cannot express my gratitude enough! Thanks again and have a great day!!

soyal (Jen)

smeagol
10-24-2002, 02:46 PM
Jen,

You are too kind! Thanks for the compliments. I'm not in the field of education, but I certainly wouldn't rule it out in the future. I'm currently a programmer for an Engineering firm in the U.S.

Again, thanks for the compliments!

Kevin

Spaull69
02-09-2009, 08:49 AM
Hi,

I am also attempting to use the same code.

One thing I am having difficulty with is having the code access a local webpage stored on my C: drive.

I have used the below code to try to have an option select the D661.htm file.

secondGroup[5][6][9]=new Option("61","C:\Documents and Settings\gspaull\My Documents\industrial sales website\D661.htm");

All http:// links work perfectly but the local file comes up with a access denied message.

I am a relative beginner so it may be something simple.

Any help would be appreciated.

Thanks