/    Sign up×
Community /Pin to ProfileBookmark

Help with Chained Select Lists

I’ve been trying to set up a form with 2 chained select lists; the first list allows a visitor to select a year, whereupon the second list is populated with months (not necessarily all months); they then select the month they want from the second list, click the Go button and should be sent to the page for that month (the pages are HTML calendars of swim meet schedules).

I’m using [url=http://www.dynamicdrive.com/dynamicindex1/chainedmenu/]this script[/url] to do the select list chaining and populating, and that aspect of it works beautifully. However, the portion of the script that Dynamic Drive added to make the script a menu resulting in a URL doesn’t seem to work properly. [i]BTW, if you go to the link above, don’t use the script included in their downloadable zip file, as they forgot to include their updated script with the new capability, instead including the original script which doesn’t have this functionality. You can get the script they are actually using [url=http://www.dynamicdrive.com/dynamicindex1/chainedmenu/chainedmenu.js]here[/url].[/i]

The bit I’m having trouble with is:

[code]
var onclickaction=””
var newwindow=””

function goListGroup(){
for (i=arguments.length-1;i>=0; i–){
if (arguments[i].selectedIndex!=-1){
var selectedOptionvalue=arguments[i].options[arguments[i].selectedIndex].value
if (selectedOptionvalue!=””){
if (onclickaction==”alert”)
alert(selectedOptionvalue)
else if (newwindow==1)
window.open(selectedOptionvalue)
else
window.location=selectedOptionvalue
break
}
}
}
}
[/code]

Note, I had to add the [b]var newwindow[/b] bit as it is referenced in DD’s script but they forgot to define it.

If I have [b]newwindow[/b] set to “1” the script works beautifully. The two select lists chain, populate and properly produce a URL that opens in a new window. If I set [b]newwindow[/b] to nothing, the script should else-out to the [b]window.location=selectedOptionvalue[/b] statement but this does not work and I am stumped as to why. All it does is refresh the current page.

Here is the HTML I’m using (a bit stripped down to show just the points relating to the script):

[code]
<head>
<script language=”javascript” src=”chainedselects.js”></script>
<script language=”javascript” src=”calendar_selector_data.js”></script>
</head>
[/code]

[code]
<body onload=”initListGroup(‘calendars’, document.calmenu.year, document.calmenu.month)”>
[/code]

[code]
<form action=”” name=”calmenu” id=”calmenu”>
<table align=”center”>
<tr>
<td><select name=”year” style=”width:95px;”></select></td>
<td><select name=”month” style=”width:95px;”></select></td>
<td><input type=”submit” value=”Go” onclick=”goListGroup(document.calmenu.year, document.calmenu.month)”>
</tr>
</table>
</form>
[/code]

And here is the data file I’ve put together that is initialized with the script:

[code]
//var hide_empty_list=true; //uncomment this line to hide empty selection lists

//var disable_empty_list=true; //uncomment this line to disable empty selection lists

addListGroup(“calendars”, “year-list”);

addOption(“year-list”, “Select Year”, “”, “”, 1);
addList(“year-list”, “2004”, “2004”, “2004”);
addList(“year-list”, “2005”, “2005”, “2005”);
addList(“year-list”, “2006”, “2006”, “2006”);

addOption(“2004”, “Select Month”, “”);
addOption(“2004”, “January”, “january.html”);
addOption(“2004”, “February”, “february.html”);
addOption(“2004”, “March”, “march.html”);
addOption(“2004”, “April”, “april.html”);
addOption(“2004”, “May”, “may.html”);
addOption(“2004”, “June”, “june.html”);
addOption(“2004”, “July”, “july.html”);
addOption(“2004”, “August”, “august.html”);
addOption(“2004”, “September”, “september.html”);
addOption(“2004”, “October”, “october.html”);
addOption(“2004”, “November”, “november.html”);
addOption(“2004”, “December”, “december.html”);

addOption(“2005”, “Select Month”, “”);
addOption(“2005”, “January”, “january.html”);
addOption(“2005”, “February”, “february.html”);
addOption(“2005”, “March”, “march.html”);
addOption(“2005”, “April”, “april.html”);
addOption(“2005”, “May”, “may.html”);
addOption(“2005”, “June”, “june.html”);
addOption(“2005”, “July”, “july.html”);
addOption(“2005”, “August”, “august.html”);
addOption(“2005”, “September”, “september.html”);
addOption(“2005”, “October”, “october.html”);
addOption(“2005”, “November”, “november.html”);
addOption(“2005”, “December”, “december.html”);

addOption(“2006”, “Select Month”, “”);
addOption(“2006”, “January”, “january.html”);
addOption(“2006”, “February”, “february.html”);
addOption(“2006”, “March”, “march.html”);
addOption(“2006”, “April”, “april.html”);
addOption(“2006”, “May”, “may.html”);
addOption(“2006”, “June”, “june.html”);
addOption(“2006”, “July”, “july.html”);
addOption(“2006”, “August”, “august.html”);
addOption(“2006”, “September”, “september.html”);
addOption(“2006”, “October”, “october.html”);
addOption(“2006”, “November”, “novemeber.html”);
addOption(“2006”, “December”, “december.html”);
[/code]

What I really want is for the 2 select lists to open the page within an iframe on the current page but right now I’m just trying to get it to open on the current page at all. Any help on this would be greatly appreciated! Thanks.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@CharlesJul 18.2004 — [font=georgia]And how are people who do not use JavaScript going to access your schedules?[/font]
Copy linkTweet thisAlerts:
@kennauthorJul 18.2004 — There will be other methods of accessing these pages on the site...this select list option is for convenience (assuming I can get it to work).
Copy linkTweet thisAlerts:
@jonfJul 19.2004 — Have you been able to get this script to result in any action? I've been trying this (and other) scripts for creating chain selections, and have been utterly unable to find any way of making them do anything more than bring up a new set of selections. I can successfully repopulate them with all my own data and connect the chains as I want, but that's as far as I can get.

I imagine I need to learn a lot more to use this chained set of selections to accomplish anything. All I want is to have the final selection result in a specific action. Preferably simply a text result on the same page, but if I could get it to result in a link to another page I could make that work for me. How do I get the final "Go" button to process the combined selections and do anything?
Copy linkTweet thisAlerts:
@kennauthorJul 19.2004 — I completely gave up on the script I detailed above. I just could not get it to do what I needed, and received no help anywhere.

I did, however, find 2 other scripts that work perfectly and are far easier to set up and use! ?

Go [url=http://www.javascriptkit.com/script/script2/triplecombo.shtml]here[/url] for the [b]Triple Combo[/b] script that lets you do a 3 select list menuing system.

Go [url=http://javascriptkit.com/script/cut183.shtml]here[/url] for the [b]Double Combo[/b] script that lets you do a 2 select list menuing system (this is the one that I am using).

Go [url=http://javascriptkit.com/script/script2/dcombotext.shtml]here[/url] for the [b]Double Combo with text[/b] description script which might be of interest to you since you mentioned you wanted to display some text on the page. This one acts like [b]Double Combo[/b] with the added feature of displaying a description for each item on the list.

Go [url=http://javascriptkit.com/script/cutindex16.shtml]here[/url] for a bunch of other select list (combo box) scripts.

And, last but not least, go [url=http://www.codingforums.com]here[/url] for a nice forum where you can get help and customizations for the above scripts (just do a search in their forum for "triple combo" etc.).

Good luck!
Copy linkTweet thisAlerts:
@jonfJul 19.2004 — Thanks much. I'll check out the scripts you mentioned. Nice to know I'm not the only one having trouble with this!
×

Success!

Help @kenn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...