rendered paste body
function pickEntityUpdateList() {
var selectBox = document.getElementById('pick_entity_list');
selectBox.options.length = 0;
selectBox.options[0] = new Option('Loading..', -1);
switch (currentType) {
case 'Customer':
req.open('post', ajaxGetEntityListCustomer, false)
break;
case 'Vessel':
req.open('post', ajaxGetEntityListVessel, false)
break;
case 'Agent':
req.open('post', ajaxGetEntityListAgent, false)
break;
default:
return;
break;
}
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.onreadystatechange = ajaxPickEntityResponse;
req.send('search=' + escape(document.getElementById('pick_entity_search').value) );
}
function ajaxPickEntityResponse() {
if(req.readyState == 4){
var ajaxResponse = req.responseXML;
var currentTag = false;
var selectBox = document.getElementById('pick_entity_list');
selectBox.options.length = 0;
for (var i = 0; i < ajaxResponse.getElementsByTagName('entity').length; i++) {
currentTag = ajaxResponse.getElementsByTagName('entity')[i];
currentName = currentTag.childNodes[0] == undefined ? '' : unescape(currentTag.childNodes[0].nodeValue);
currentValue = currentTag.getAttribute("value");
selectBox.options[i] = new Option(currentName, currentValue);
}
if ( ajaxResponse.getElementsByTagName('entity').length == 0 ) {
selectBox.options[0] = new Option('(no matches)', -1);
}
}
}