Forum Moderators: open

Message Too Old, No Replies

Dynamic select options

         

druidjaidan

2:29 pm on Aug 17, 2007 (gmt 0)

10+ Year Member



I'm using the following code to show only compatible options. It works fine in IE, but not in Opera or IE. In IE it does not diplay all of the options but kinda randomly. In Opera the dev tools show that the display style is correctly set to none...but it displays it anyway. So at least with opera it seems this way of compatibility checking might not be viable.

Is the only way to accomplish something like this to completely rebuild the options list each time?


function checkcompat(event)
{
/*Does compatability checking for the page. This is still incomplete, as compat checking is needed to be done on the software also.
as well as when compatability options change the currently selected option should change to match.*/
var motherref = document.getElementById('MotherboardSel').value;
var boardcompats = mothercompat[motherref];
var orderform = document.getElementById('theorderform');
for (i = 0; i < orderform.CPU.options.length; i++) {
if (boardcompats['Socket'] == compat['CPU'][i]) {
orderform.CPU.options[i].style.display = "block";
}
else {
orderform.CPU.options[i].style.display = "none";
}
}
for (i = 0; i < orderform.Memory.options.length; i++) {
if (boardcompats['Memory'] == compat['Memory'][i]) {
orderform.Memory.options[i].style.display = "block";
}
else {
orderform.Memory.options[i].style.display = "none";
}
}
for (i = 0; i < document.getElementById('Video_CardSel').options.length; i++) {
if (compat['Video Card'][i] == "SLI" ¦¦ compat['Video Card'][i] == "Crossfire") {
var code = compat['Video Card'][i];
if (boardcompats[code] == "y") {
document.getElementById('Video_CardSel').options[i].style.display = "block";
}
else {
document.getElementById('Video_CardSel').options[i].style.display = "none";
}
}
else {
document.getElementById('Video_CardSel').style.display = "block";
}
}
return;
}

Sorry even with code tags the forums seem to eat my tabs and whitespacing

Arno_Adams

2:48 pm on Aug 17, 2007 (gmt 0)

10+ Year Member



Hi,

try removing the options from the select lists instead of toggling their display property.

HTH, AA