/* AL declare the global fieldname variable - the id to update*/var fieldnameid = "dd";var clearfieldid = "";function updateOption(key,codesetpath,codesetview,ot,ov,fieldid,clearid) {/* only works in Mozilla as IE has bug (...again)) use JSON for IE */var codesetcolumns = ""; /* check codeset path is populated otherwise use basehref */ if (codesetpath = "") {	   }     /* check if specifc cols required */ if (ot != "" & ov != "")  {	 codesetcolumns = "&ot=" +ot + "&ov=" +ov;   }var url = codesetpath + 'doCSROL?openpage';/* set the global id to the passed id*/fieldnameid = fieldid;clearfieldid = clearid;var params = '&key=' +  key +  '&spacer=1' + "&local=true" + "&view=" +codesetview + codesetcolumns;/* make the request */var myAjax = new Ajax.Request(			url, 			{				method: 'get', 				parameters: params, 				onComplete:  processResponse,				onFailure: processResponse			});};function processResponse(originalRequest)	{		alert(originalRequest.responseText);	alert("getting " + fieldnameid);	alert(document.getElementById(fieldnameid).innerHTML);	document.getElementById(fieldnameid).innerHTML = originalRequest.responseText;			document.getElementById("iedd2").innerHTML = originalRequest.responseText;			alert ('ie');		/* IE Bug  http://support.microsoft.com/default.aspx?scid=kb;en-us;276228 */		/* $(fieldnameid).innerHTML = originalRequest.responseText;	*/	/* clear any fields we need to */	if (clearfieldid != "") {		$(clearfieldid).innerHTML = "";				};	};function reportError(originalRequest){ 		/* IE always returns the error */	$(fieldnameid).innerHTML = originalRequest.responseText;		/* clear any fields we need to */	if (clearfieldid != "") {		$(clearfieldid).innerHTML = "";				};	};/* ================================================================ *//* 													Return JSON 												    *//* ================================================================ */function updateOptionJSON(key,codesetpath,codesetview,ot,ov,fieldid,clearid) {var codesetcolumns = ""; /* check codeset path is populated otherwise use basehref */     /* check if specifc cols required */ if (ot != "" & ov != "")  {	 codesetcolumns = "&ot=" +ot + "&ov=" +ov;   }var url = codesetpath + 'doCSROLJSON?openpage';/* set the global id to the passed id*/fieldnameid = fieldid;clearfieldid = clearid;var params = 'key=' +  key +  '&spacer=1' + "&local=true" + "&view=" +codesetview + codesetcolumns + "&fld=" + fieldnameid;url = codesetpath   + 'doCSROLJSON?openpage' /* +params */ ;/* make the request */var myAjax = new Ajax.Request(			url, 			{				method: 'get', 				parameters: params,				onSuccess: processResponseJSON,				onFailure: processResponseJSON			});};function processResponseJSON(originalRequest)	{	page = "";  	/* create the object */	page = eval('(' + originalRequest.responseText+ ')');	/* alert( originalRequest.responseText);	alert('setting dd =  fieldnameid ' + fieldnameid + ' >> fld = ' + page.fld); */  	/* get and clear the existing options */  	var dd = $(page.fld);	dd.options.length = 0;		/* alert('array elements ' + page['lookupresult'].length); */			/* now loop through and create an option list from the object */		    for(i = 0; i < page['lookupresult'].length; i++) {	    	    dd.options[dd.options.length] = new Option(page['lookupresult'][i].optiontext , page['lookupresult'][i].optionvalue);	    	    }		/* add in the spacer <option value="" class="spacer">_______________</option> 	    dd.options[dd.options.length] = new Option('', '_______________');  */	}/* ================================================================ *//* 													Return a table 												    *//* ================================================================ */function processResponseJSON2(originalRequest)	{	page = eval('(' + originalRequest.responseText+ ')');		alert(page);		  table =     '<table>';    alt = '';    for(i = 0; i < page['lookupresult'].length; i++) {        table +=         '<tr class="'+alt+'">' +                         '<td>' + page['lookupresult'][i].optionvalue   + ',</td>' +                         '<td>' + page['lookupresult'][i].optiontext  + '</td>' +                         '</tr>';        (alt == '')            ?   alt = 'alt'            :   alt = '';    }    table += '</table>';        alert(table);           	$('newoption').innerHTML= table;  	  	/* now loop through and create an option list */  	var dd = $(fieldnameid);	dd.options.length = 0;	table = '';		/* now loop through and create an option list from the object */		    for(i = 0; i < page['lookupresult'].length; i++) {	    	    dd.options[dd.options.length] = new Option(page['lookupresult'][i].optiontext , page['lookupresult'][i].optionvalue);	    	    }				/* dd.options[dd.options.length] = new Option('\u00A30','0'); */  	 //   contain.innerHTML = table;			}/* ================================================================ *//* 												deleteOptions 													    *//* ================================================================ */function deleteOptions(dropdowns) {         /* AG - The id of the dropdowns must be delimited by commas -  build array from passed string */         var ddarray = dropdowns.split(/,/);         if (ddarray){                         /* now loop through array of dropdown boxes */                         for (var d=0; d < ddarray.length; d++) {                                 var obj = document.getElementById(ddarray[d]);                                 if(obj){                                         totaloptions = obj.options.length;                                         for (var i=0; i < totaloptions; i++) {                                                         obj.options[0] = null;                                         }                                 }                         }  /* for loop */                 } /* ddarray */ } 