0

I have used the following piece of code to set defailt value of a DropDownn List in Sharepoint List form

for ( var i = 0; i < getField('select','County').options.length; i++ ) {
if ( getField('select','County').options[i].text == "New County" ) {
getField('select','County').options[i].selected = true;
}
}

The loop works fine on all other browser except IE8, how can i solve this issue

i get the error in IE8 as:

options is null or not an object

EDIT:

function getField(fieldType,fieldTitle) 
 {     
   var docTags = document.getElementsByTagName(fieldType);     
   for (var i=0; i < docTags.length; i++)
    {         
      if (docTags[i].title == fieldTitle)
      { 
         return docTags[i]; 
      }     
    } 
 }
4

1 回答 1

1

上述异常不是因为 IE8,而是因为在 sharepoint 中,当 select 中的列表值超过 20 时,控件呈现为input而不是select

当我在 IE9 中尝试时,我在选择中只有很少的值,而在服务器上它是 IE8,并且在列表中有很多值。

于 2012-05-23T04:25:46.737 回答