BootNic wrote:
>>"Adam Tilghman" <> wrote:
>>news: groups.com....
>>
>>Hi all,
>>
>>I have found that IE doesn't seem to respect the <SELECT> "multiple"
>>attribute when set using DOM methods, although the
>>attribute/property seems to exist and is updated properly. Those
>>changes just don't make it onto the screen.
>>
>>Am I doing something wrong here?
>>If not, is there a better feature test I can use than
>>"appName.match()"?
>>
>>if (navigator.appName.match(/Internet Explorer/)) {
>> unselist = document.createElement("<SELECT MULTIPLE>");
>>} else {
>> unselist = document.createElement("SELECT");
>> unselist.multiple = true;
>>}
>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
> <html>
> <head>
> <meta http-equiv="content-type" content=
> "text/html; charset=windows-1252">
> <title></title>
> <script type="text/javascript">
> function pu(){
> var info=['bob','bobbie','bobbie sue'];
> var clone,x,i,j,sel,p;
> if(document.createElement && document.insertBefore && document.appendChild){
If document.createElement is supoprted, then support for insertBefore
and appendChild can probably be safely infered.
Why wait until later to test for other necessary features? Do it all
up-front, no point in making the new select if you can't add it to the
document.
> sel = document.createElement('select');
> p = document.createElement('p');
> document.forms[0].insertBefore(p,document.forms[0].childNodes[0]);
> p.appendChild(sel);
> sel.id='f';
> sel.size='3';
> sel.multiple='true';
You must add a name attribute or the select will not be sucessful and
won't be submitted.
> for (i=0, j=info.length; i<j; i++) {
> x = info[i];
> sel.appendChild(document.createElement('option'));
> sel.options[i].text=sel.options[i].value=x;
Some versions of IE have trouble with creating options that way, try:
for (i=0, j=info.length; i<j; i++) {
sel[sel.options.length] = new Option(info[i], info[i]);
}
> }
> if(document.replaceNode && document.cloneNode && document.getElementById){
> clone=document.getElementById('f').cloneNode(true) ;
What is the point of cloning a node, then replacing it with itself?
> document.getElementById('f').replaceNode(clone);
> for (i=0, j=clone.options.length; i<j; i++) {
> clone.options[i].selected=false;
When you cloned the select, you did a deep clone so all the options are
already cloned. Having cloned them, you don't add them or replace the
existing ones. You can set the options as selected or not when they are
created.
> }}}
> document.body.style.display='none';
> document.body.style.display='';
I don't see the point of that.
[...]
function pu()
{
var info=['bob','bobbie','bobbie sue'];
var sel, p;
if( !document.createElement ||
!document.insertBefore ||
!document.appendChild){
return
}
sel = document.createElement('select');
p = document.createElement('p');
document.forms[0].insertBefore(p,document.forms[0].childNodes[0]);
p.appendChild(sel);
sel.id = 'f';
sel.name = 'f';
sel.size = '3';
sel.multiple = 'true';
for (var i=0, j=info.length; i<j; i++) {
sel[sel.options.length] = new Option(info[i], info[i]);
}
}
--
Rob
|