function addSuggest(fieldName, contextId, otherParams) { //we need to add the div to the fields first... if (contextId == undefined) { contextId = 0; } if (otherParams == undefined) { otherParams = ""; } try { var addLastRequest = ""; if(typeof(setLastRequest) !== 'undefined') { addLastRequest = "&suggestLastRequest=" + setLastRequest; } var field = eval("document.entry_form." + fieldName); field.id = fieldName; var fieldDiv = document.createElement("div"); fieldDiv.id = fieldName+"_choices"; fieldDiv.className = "autocomplete"; field.parentNode.appendChild(fieldDiv); //next we're going to add the autocomplete call... new Ajax.Autocompleter(fieldName, fieldName+"_choices", "", {parameters:'page=alcea.mod.suggest.CornerSuggest&CONTEXT='+contextId+'&suggest=1'+addLastRequest+otherParams+'&field='+fieldName, afterUpdateElement : lookupField}); } catch(err) { //This won't apply for View Bug } } function addLookupToDropdown(fieldName) { try { var field = eval("document.entry_form." + fieldName); var origOnchange = field.onchange; field.onchange = function(){ if (origOnchange) changeField(field); var li = document.createElement("li"); li.innerHTML = field.value; lookupField(field,li); } } catch(err) { //This won't apply for View Bug } } var keyUpLength = 0; function addLookupToString(fieldName) { try { var field = eval("document.entry_form." + fieldName); field.onkeyup = function() { if (field.value.length >= onKeyUpLength) { var li = document.createElement("li"); li.innerHTML = field.value; lookupField(field,li); } } } catch(err) { //This won't apply for View Bug } } function lookupField(fieldName,li) { //var field = eval("document.entry_form."+fieldName); //if (field.value.length < 4) { // return false; //} try { var handlerFunc = function(t) { eval(t.responseText); } var errFunc = function(t) { alert('Error ' + t.status + ' -- ' + t.statusText); } new Ajax.Request('', {parameters:'page=alcea.mod.suggest.CornerSuggest&origIndex='+li.getAttribute("origIndex")+'&lookup=1&field='+fieldName.name+'&'+fieldName.name+'='+escape(fieldName.value), onSuccess:handlerFunc, onFailure:errFunc}); } catch(err) { txt="There was an error on this page for lookupField.\n\n"; txt+="Error description: " + err.description + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); } } function updateLookupField(fieldName,fieldVal) { var field = eval('document.entry_form.'+fieldName); field.value = fieldVal; } function updateLookupDropdownField(fieldName,fieldVal) { var field = eval('document.entry_form.'+fieldName); for (var i = 0; i < field.options.length; ++i) { //alert("Matching: " + fieldVal.toLowerCase() + " - Against: " + field.options[i].value.toLowerCase()); if (field.options[i].value.toLowerCase() == fieldVal.toLowerCase()) { field.selectedIndex = i; } } }