Does a SELECT element (listbox) need to be inside
a FORM element?
The code I'm playing with:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<script language="javascript" type="text/javascript">
/*
* ChangeBGColor(this)
*/
function ChangeBGColor(oSel) {
// FAILING IN IE...
//document.body.style.backgroundColor="#"+oSel.value ;
//
// alert(document.bgColor); // <--- WORKS IN IE and FF
// alert(oSel.value); // <-- FAILING IN IE
// FAILING IN IE...
// alert("oSel.options(oSel.selectedIndex).value = #" + oSel.options(oSel.selectedIndex).value);
if (document.bgColor) {
// FAILS in IE...
document.bgColor="#" + oSel.options(oSel.selectedIndex).value;
//alert(oSel.selectedIndex); // WORKS in IE. Returns index.
}
else {
//unsupported browser
alert("Your browser fails to fully support javascript.");
}
//alert(oSel.value); // FAILS in IE. Empty string (?).
//alert(oSel.name); // WORKS IN IE. Returns name of listbox.
return;
}
</script>
</head>
<body>
<p><select size="1" name="cbxSelectColor" tabindex="0"
title="Select A Color" onchange="javascript:ChangeBGColor(this);">
<option>002244</option>
<option>000000</option>
<option>ff0000</option>
<option>00ff00</option>
<option>0000ff</option>
<option>777777</option>
<option>003366</option>
<option>004488</option>
<option>0055AA</option>
</select></p>
</body>
</html>
Any suggestions as to what's going wrong? I tried it under both
the XHTML transitional and the strict doctypes.
--
Jim Carlock
Post replies to the newsgroup, thanks.