View Full Version : works in Netscape, NOT in IE, WHY?

07-10-2002, 03:34 PM
This is an array (javascript) that populates one drop-down depending on what the first drop-down value is:
//this JS populates the second drop-down
<!-- Begin
team = new Array(
new Array(
new Array("Please select a name", "VP"),
new Array("David", "David<dg@entertainment.com>"),
new Array("Hugh", "Hugh<hm@entertainment.com>"),
new Array("Stephen", "Stephen<sm@woodbineentertainment.com>")
new Array(
new Array("Please select a name", "VP"),
new Array("Tom", "Tom<tv@entertainment.com>"),
new Array("Frank", "Frank<fl@entertainment.com>")
new Array(
new Array("Please select a name", "VP"),
new Array("Steve", "Steve<sw@woodbineentertainment.com>")
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];
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
// End -->
//This is the first drop-down, not the whole form
<select name="Dept" onChange="fillSelectFromArray(this.form.VPName, ((this.selectedIndex == -1) ? null : team[this.selectedIndex-1]));">
<option value="-1">Select Your Dept.</option>
<option value="1">Administration </option>
<option value="2">Accounting </option>
<option value="3">Broadcasting </option>

//second drop-down
<!--select name="AuthBy"-->
<select name="VPName">
<option value="VP"><b><font face="Arial, Helvetica, sans-serif" size="2">Please
select a name</font></b></option>

The problem is that i am using JS for a 'Back' link,
<a href = 'javascript:history.back();'>Change Request</a>
for the next page, but when the user uses the 'Back' link, the second-dropbox never populates in IE (5.x or 6).
Anyone have an idea why? THANKS!!!!

Soldier Bob
07-10-2002, 04:26 PM
I didnt get a chance to fully understand the code.

But if you think the back link is the cause of your qualm. have you tried this:

<a href="javascript:void(0)" onclick="history.back();return false">Change Request</a>

dont know if that fixes anything...

something was told to me before about using javascript: in the href link and JS not working...

-S. Bob

07-10-2002, 04:36 PM
thanks, but i've figured it out...
i had to add an onChange again to the end of the form