Monday 25 March 2013

Dropdown Unchanged event in share point for lookup exceeding value 20



http://social.technet.microsoft.com/Forums/en/sharepointadmin/thread/7003ef85-38bf-450b-91b4-4725733c5384


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]
        }
    }
}

2. I use the following lines of code to determine if the control is a lookup with < 19 options or one with > 19 options and accordingly set my function to be called either on "onchange" event or on "onblur" event

if(getField('select','Role') != null){   //incase of lookup having < 19 options
 if(getField('select','Role').type == 'select-one'){
  getField('select','Role').onchange = function() {syncDropDowns()};
 }
}else if(getField('input','Role') != null){  //incase of lookup having > 19 options
 if(getField('input','Role').type == 'text'){
  getField('input','Role').onblur = function() {syncDropDowns()};
 }
}




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]
        }
    }
}

2. I use the following lines of code to determine if the control is a lookup with < 19 options or one with > 19 options and accordingly set my function to be called either on "onchange" event or on "onblur" event

if(getField('select','Role') != null){   //incase of lookup having < 19 options
 if(getField('select','Role').type == 'select-one'){
  getField('select','Role').onchange = function() {syncDropDowns()};
 }
}else if(getField('input','Role') != null){  //incase of lookup having > 19 options
 if(getField('input','Role').type == 'text'){
  getField('input','Role').onblur = function() {syncDropDowns()};
 }
}


or simple call the spservices j query and use following method to convert the input field to select.

$().SPServices.SPComplexToSimpleDropdown({
 columnName: "State"
});

No comments:

Post a Comment