> Using Mozilla et al, choosing an option from both lists will result in > the correct response when 'Show Me' is clicked. But IE only shows the > result from the first SELECT box. Any ideas why / how to fix this?
> The function I'm using: > function updateList(what) > { > // This dynamically populates the CurrentPositionPicks select box in > the resume page > // depending on what one was selected in the LevelOne select box. > for (var i=0;i<document.Resume.CurrentPositionPicks.length;i++) // > empty the list > { > document.Resume.CurrentPositionPicks.options.length=0; > }
> // LevelOnePicks is the top level select box in the resume form > // CurrentPositionPicks is the dynamically generated select list > var CurrentPositionPicks=document.Resume.CurrentPositionPicks; > for (var i=0;i<document.Resume.LevelOnePicks.length;i++) > { > if (document.Resume.LevelOnePicks.options[i].selected) > { > var ThisList=eval(TopLevel[i].Name); // get the array name to use > for (var j=0; j < ThisList.length; j++) > { > CurrentPositionPicks.options[j]=new Option; > CurrentPositionPicks.options[j].text=ThisList[j]; > } > } > } > }
The two browsers handle multiple selects differently. To get selected option values/texts cross-browser, you need to loop the options and examine them. In addition, your updateList() function isn't setting option values, just displayed text. Some browsers will substitute the latter for the former but, don't rely on it...set both.
function Output() { var o, picked = [], msel = document.Resume.CurrentPositionPicks; for (var i = 0, l = msel.length; i < l; ++i) { if ((o = msel.options[i]).selected) picked.push(o.text); } alert( 'You chose\n' + document.Resume.LevelOnePicks.value + ':' + picked.join(' | ') );