...

View Full Version : triple combo box



needhelp26
08-09-2004, 06:28 PM
Here is a script from Javascriptkit example:

group[0][0]=new Option("---Select2---"," ");

group[1][0]=new Option("Now Select This One"," ");
group[1][1]=new Option("JavaScript","47");
group[1][2]=new Option("DHTML","46");
group[1][3]=new Option("CGI","45");

what does the "47" "46" and "45" do?

If I want to add another 3rd group:

group[0][0]=new Option("---Select3---"," ");

group[1][0]=new Option("Now Select This One"," ");
group[1][1]=new Option("JavaScriptkit","47");' what no will I give here?
group[1][2]=new Option("DHTMLsamples","46");
group[1][3]=new Option("CGIexamples","45");

please someone explain this example. Thanks.

glenngv
08-10-2004, 04:19 AM
That number which is the 2nd parameter of the Option object will go to the value attribute of the <option> tag:

<select>
<option value="47">Javascript</option>
</select>

The value attribute (of the selected option) is the one submitted to the server. The text attribute (in between option tag) is what the user sees. If the value attribute is not specified, the text attribute will be the one submitted to the server.

needhelp26
08-11-2004, 04:14 AM
Thankyou.

needhelp26
08-23-2004, 03:50 AM
I have another question pertaining to this code. I want to use the script as Include file within the html page. I want to insert because I do have a huge new option for each drop down box, and it is taking long time to load the page.

1. By inserting the include file(script), will it reduce the time of loading?
2. where should I include the .js file? I have showed a sample in red.

<html>
<head>
<title>ComboBox[4]</title>
<script src="include.js" type="text/javascript"></script>
</head>
<body>

<FORM name="CBN">
<table border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td nowrap height="11"> &nbsp;

<select name="CBN1" size="1" style="font-family: Lucida Console,Verdana, Tahoma, Arial; font-size: 9"
onChange="ReDirect1(this.options.selectedIndex)">
<option selected>---Select1-------------</option>
<option>1</option>
<option>2</option>
</select>
<select name="CBN2" size="1" style="font-family: Lucida Console,Verdana, Tahoma, Arial; font-size: 9"
onChange="ReDirect2(this.options.selectedIndex)">
<option value=" " selected> </option>
<option value=" " selected>---Select2--------------</option>
<option value=" " selected>---Select2--------------</option>
</select>
<select name="CBN3" size="1" style="font-family: Lucida Console,Verdana, Tahoma, Arial; font-size: 9"
onChange="ReDirect3(this.options.selectedIndex)">
<option value=" " selected> </option>
<option value=" " selected>---Select3----------------</option>
<option value=" " selected>---Select3----------------</option>
</select>
<select name="CBN4" size="1" style="font-family: Lucida Console,Verdana, Tahoma, Arial; font-size: 9"
onChange="ReDirect(this.options.selectedIndex)">
<option value=" " selected> </option>
<option value=" " selected>---Select4----------------</option>
<option value=" " selected>---Select4----------------</option>
</select>
</body>
</html>

glenngv
08-24-2004, 05:23 AM
The Triple Combo script by Javascriptkit should be inserted AFTER the <select> elements.

inko9nito
12-15-2006, 01:49 AM
In the same script, in the third combo box if you click on an option it loads a new page, and the "value" tells what url to load.



secondGroup[2][2][0]=new Option("Now Select A Page"," ");
secondGroup[2][2][1]=new Option("News.com","http://www.news.com");
secondGroup[2][2][2]=new Option("Wired","http://www.wired.com");

But how do I tell it to just stay at that option and not load any new pages? If I leave the value part blank it just reloads the page for some reason.

URL of the script: http://www.javascriptkit.com/script/script2/triplecombo.shtml


EDIT: Nevermind. All you have to do is remove onChange from the third combo box declaration.

dframeli
12-16-2008, 07:42 PM
I have a fairly extensive implementation of the Triple Combo Box described in NeedHelp26's original message.

I'm "very" new to js... Can someone explain once more (in very plain language) what the new Option values 47, 46 and 45 represent?

group[1][0]=new Option("Now Select This One"," ");
group[1][1]=new Option("JavaScript","47");
group[1][2]=new Option("CSS","46");
group[1][3]=new Option("Ajax","45");

group[2][0]=new Option("Now Select This One"," ");
group[2][1]=new Option("General News","115");
group[2][2]=new Option("Technology News","116");

Also, since I'm creating my own Triple Combo, can someone also explain how I can manually calculate the values for all (9) of my groups?

Thanks!

dframeli
03-03-2009, 03:31 PM
glenngv,

With regards to the Cut and Paste Triple Combo and your explaination above, I understood the text "Javascript", "CSS" and "Ajax" are the text the user sees, and that "47", "46" and "45" are values sent back to the server.

However, I'm still not getting the whole picture :(

What do these values represent to the code and/or to the server? And why are the first series of numbers in reverse order?

I can't just leave the values set to null. When I do, the code refuses to function properly. So the values must be used by the server for something...

I have many additional menus to create.

So I can create them, can you explain (in simple terms :)) how do I go about calculating the correct values to input for each additional set of menus that I wish to add?

If 47, 46 and 45 are the first series and 115, 116 and 117 are the second series, what is the third series?

Thanks,
Dale


group[1][0]=new Option("Now Select This One"," ");
group[1][1]=new Option("JavaScript","47");
group[1][2]=new Option("CSS","46");
group[1][3]=new Option("Ajax","45");

group[2][0]=new Option("Now Select This One"," ");
group[2][1]=new Option("General News","115");
group[2][2]=new Option("Technology News","116");

dframeli
03-20-2009, 04:02 PM
Please disregard. I have it fugured out now...

For anyone else that was wondering, all that matters is that these values be unique.

For example, you cannot use the same value more than once.


group[1][0]=new Option("Now Select This One"," ");
group[1][1]=new Option("JavaScript","47");
group[1][2]=new Option("CSS","46");
group[1][3]=new Option("Ajax","45");

group[2][0]=new Option("Now Select This One"," ");
group[2][1]=new Option("General News","115");
group[2][2]=new Option("Technology News","116");



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum