Hi, I am looking for help altering the script located at: http://javascript.internet.com/forms/auto-drop-down.html
This script creates a drop down based on the 1st slection popultates the 2nd dropdown
I need to use this script twice on the same form. My problem is that I change the select box names on the form and then in the script but it doesn't seem to work… I also had edited the select - onchange: fillSelectFromArray(this.form.Team, ((this.selectedIndex == -1) ? null : team[this.selectedIndex-1]));
I replace "Team" with the new select field "name" I also change "Team" to the new "name" in the code: team = new Array(
It doesn't seem to work, is there something I am missing in either the select - onchange or script? Any help would be appreciated… thank you for your time.
96turnerri
09-21-2003, 12:29 PM
could you post ur scipt onto this thread then i can av a look?
toastg
09-21-2003, 01:27 PM
sure here is the script: I need to change the menu name from "Team" to "Location" anytime i change the "team" to location it stops working.... thanks for any help....
<!-- TWO STEPS TO INSTALL AUTO DROP DOWN:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
team = new Array(
new Array(
new Array("Saku Koivu", 39482304),
new Array("Martin Rucinsky", 34802389),
new Array("Jeff Hackett", 39823498),
new Array("Sheldon Sourray", 87587343),
new Array("Richard Zednik", 68798735),
new Array("Brian Savage", 98098509),
new Array("Stephane Robidas", 49490583),
new Array("Patrice Brisebois", 32898334),
new Array("Oleg Petrov", 92340934),
new Array("Chad Kilger", 34923409),
new Array("Benoit Brunet", 59384093),
new Array("Jan Bulis", 83948023),
new Array("Patrick Traverse", 41239812),
new Array("Jose Theodore", 98402398),
new Array("Craig Darby", 82393434),
new Array("Patric Poulin", 34290348),
new Array("Karl Dykhuis", 89092834)
),
new Array(
new Array("Mario Lemieux", 23840238),
new Array("Jaromir Jagr", 92390484),
new Array("Robert Lang", 29048203),
new Array("Alexei Kovalev", 94098230),
new Array("Jean-Sebastien Aubin", 39234923),
new Array("Kevin Stevens", 29345423)
),
null,
new Array(
new Array("Alexei Yashin", 20394802),
new Array("Daniel Alfredson", 34982039),
new Array("Marian Hossa", 92348902),
new Array("Patrick Lalime", 98203894),
new Array("Radek Bonk", 98234902)
)
);
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
}
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
its when i change the "team" property that it doesnt work
96turnerri
09-24-2003, 11:58 AM
why do you need to change it to team cant you just leave it as location if you do insist on changing it you will need to change all refernces to team to location
toastg
09-24-2003, 01:21 PM
actually I need to chage "Team" to location - one reason is I am trying to get 2 sets of htese menus working in one form - having the same name would be a conflict... also just for debuggin purposes down the raod - "Team" wont make much sence if someone else need to modify something....
96turnerri
09-24-2003, 05:11 PM
to change it to location you need to change all three of the 'team's to location
toastg
09-24-2003, 07:59 PM
yeah I have change all three of the "Teams" to "location but it bombs out on me....
96turnerri
09-25-2003, 04:57 AM
i may be wrong but i think it is written coded, if you know what i mean, cannot be changed, when i change it to team not location a big error come up saying cannot find file then a big list of the array
toastg
09-25-2003, 08:43 AM
yeah it will look for this js script in the header as follows:
Just note i change line2: team = new Array(
to: location = new Array(
<!-- Begin
team = new Array(
new Array(
new Array("[SELECT]"),
new Array("MH 100"),
new Array("MH 125"),
new Array("MH 145"),
new Array("MH 150"),
new Array("MH 155"),
new Array("MH 1554"),
new Array("MH 175"),
new Array("MH 200"),
new Array("MH 300"),
new Array("MH 330"),
new Array("MH 350"),
new Array("MH 400"),
new Array("MH 865"),
new Array("MH Day Ctr"),
new Array("MH Network Mgmt")
),
new Array(
new Array("[SELECT]"),
new Array("LIJ Main"),
new Array("NHP 400 Bldg"),
new Array("NHP 410 Bldg"),
new Array("NHP 420 Bldg"),
new Array("NHP Finkelstein"),
new Array("NHP Marcus Ave"),
new Array("PB3 Trailer"),
new Array("PB6 Trailer"),
new Array("Queens Day Center"),
new Array("Queens Dialysis")
),
new Array(
new Array("[SELECT]"),
new Array("Hillside Main"),
new Array("E. Sloman Lowenstein"),
new Array("Kaufman"),
new Array("L. Lowenstein"),
new Array("Littauer Bldg.")
),
new Array(
new Array("[SELECT]"),
new Array("NHP Schneiders"),
new Array("MH Schneider's at Hewlett")
),
new Array(
new Array("[SELECT]"),
new Array("Plainview Main")
),
new Array(
new Array("[SELECT]"),
new Array("Syosset Main"),
new Array("Syosset Ambulance")
),
new Array(
new Array("[SELECT]"),
new Array("Glen Cove Main"),
new Array("Oyster Bay Fam. Practice")
),
new Array(
new Array("[SELECT]"),
new Array("FH Main")
),
new Array(
new Array("[SELECT]"),
new Array("Franklin Main"),
new Array("Franklin Homecare")
),
new Array(
new Array("[SELECT]"),
new Array("Carrillon Nursing Home & Rehab"),
new Array("Center for Autism/Pain Center"),
new Array("Commack Pediatrics"),
new Array("Grandell Rehab. And Nursing"),
new Array("Gurwin Jewish Geriatric Center"),
new Array("Hauppage Main")
)
);
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
}
}
// End -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
team = new Array(
new Array(
new Array("[SELECT]"),
new Array("MH 100"),
new Array("MH 125"),
new Array("MH 145"),
new Array("MH 150"),
new Array("MH 155"),
new Array("MH 1554"),
new Array("MH 175"),
new Array("MH 200"),
new Array("MH 300"),
new Array("MH 330"),
new Array("MH 350"),
new Array("MH 400"),
new Array("MH 865"),
new Array("MH Day Ctr"),
new Array("MH Network Mgmt")
),
new Array(
new Array("[SELECT]"),
new Array("LIJ Main"),
new Array("NHP 400 Bldg"),
new Array("NHP 410 Bldg"),
new Array("NHP 420 Bldg"),
new Array("NHP Finkelstein"),
new Array("NHP Marcus Ave"),
new Array("PB3 Trailer"),
new Array("PB6 Trailer"),
new Array("Queens Day Center"),
new Array("Queens Dialysis")
),
new Array(
new Array("[SELECT]"),
new Array("Hillside Main"),
new Array("E. Sloman Lowenstein"),
new Array("Kaufman"),
new Array("L. Lowenstein"),
new Array("Littauer Bldg.")
),
new Array(
new Array("[SELECT]"),
new Array("NHP Schneiders"),
new Array("MH Schneider's at Hewlett")
),
new Array(
new Array("[SELECT]"),
new Array("Plainview Main")
),
new Array(
new Array("[SELECT]"),
new Array("Syosset Main"),
new Array("Syosset Ambulance")
),
new Array(
new Array("[SELECT]"),
new Array("Glen Cove Main"),
new Array("Oyster Bay Fam. Practice")
),
new Array(
new Array("[SELECT]"),
new Array("FH Main")
),
new Array(
new Array("[SELECT]"),
new Array("Franklin Main"),
new Array("Franklin Homecare")
),
new Array(
new Array("[SELECT]"),
new Array("Carrillon Nursing Home & Rehab"),
new Array("Center for Autism/Pain Center"),
new Array("Commack Pediatrics"),
new Array("Grandell Rehab. And Nursing"),
new Array("Gurwin Jewish Geriatric Center"),
new Array("Hauppage Main")
)
);
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
}
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
place = new Array(
new Array(
new Array("[SELECT]"),
new Array("MH 100"),
new Array("MH 125"),
new Array("MH 145"),
new Array("MH 150"),
new Array("MH 155"),
new Array("MH 1554"),
new Array("MH 175"),
new Array("MH 200"),
new Array("MH 300"),
new Array("MH 330"),
new Array("MH 350"),
new Array("MH 400"),
new Array("MH 865"),
new Array("MH Day Ctr"),
new Array("MH Network Mgmt")
),
new Array(
new Array("[SELECT]"),
new Array("LIJ Main"),
new Array("NHP 400 Bldg"),
new Array("NHP 410 Bldg"),
new Array("NHP 420 Bldg"),
new Array("NHP Finkelstein"),
new Array("NHP Marcus Ave"),
new Array("PB3 Trailer"),
new Array("PB6 Trailer"),
new Array("Queens Day Center"),
new Array("Queens Dialysis")
),
new Array(
new Array("[SELECT]"),
new Array("Hillside Main"),
new Array("E. Sloman Lowenstein"),
new Array("Kaufman"),
new Array("L. Lowenstein"),
new Array("Littauer Bldg.")
),
new Array(
new Array("[SELECT]"),
new Array("NHP Schneiders"),
new Array("MH Schneider's at Hewlett")
),
new Array(
new Array("[SELECT]"),
new Array("Plainview Main")
),
new Array(
new Array("[SELECT]"),
new Array("Syosset Main"),
new Array("Syosset Ambulance")
),
new Array(
new Array("[SELECT]"),
new Array("Glen Cove Main"),
new Array("Oyster Bay Fam. Practice")
),
new Array(
new Array("[SELECT]"),
new Array("FH Main")
),
new Array(
new Array("[SELECT]"),
new Array("Franklin Main"),
new Array("Franklin Homecare")
),
new Array(
new Array("[SELECT]"),
new Array("Carrillon Nursing Home & Rehab"),
new Array("Center for Autism/Pain Center"),
new Array("Commack Pediatrics"),
new Array("Grandell Rehab. And Nursing"),
new Array("Gurwin Jewish Geriatric Center"),
new Array("Hauppage Main")
)
);
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
}
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->