Pagina Jsp che chiama tramite ajax alcuni valori (comune, provincia, codice comune).

codice:
<tr>
        <td>
         <table cellspacing=0 style="padding-right:1px;">
          <tr>
           <td class="whitebg" style="border: 1px dashed #00A160;">
            <table cellpadding=0 cellspacing=0>
             <tr>
              <td class="whitebg" valign=top><font class=numerino>17</font></td>
              <td class="whitebg"><input type="text" name="qa017" value="<%=((org.apache.struts.action.DynaActionForm)request.getAttribute("Quadro4Form")).getString("qa017")%>" id="qa017" autocomplete="off" style="width:420px;" onchange="datiModificati();" maxlength="36" onkeyup="completa();" onfocus="inizializza('comuni3','qa017','qa018','qa019');"/>
              	<div  id="comuni3" style="position:absolute;  overflow-y: auto; height: 150px;"  onmouseover="handlePopupOver()" onmouseout="handlePopupOut()"></div>
              </td>
             </tr>
            </table>
           </td>
          </tr>
         </table>
        </td>
        <td>
         <table cellspacing=0 style="padding-right:1px;">
          <tr>
           <td class="whitebg" style="border: 1px dashed #00A160;">
            <table cellpadding=0 cellspacing=0>
             <tr>
              <td class="whitebg" valign=top><font class=numerino>18</font></td>
              <td class="whitebg"><html:text property="qa018" styleId="qa018" style="width:80px;" onchange="datiModificati();" maxlength="2" /></td>
             </tr>
            </table>
           </td>
          </tr>
         </table>
        </td>
        <td>
         <table cellspacing=0 style="padding-right:1px;">
          <tr>
           <td class="whitebg" style="border: 1px dashed #00A160;">
            <table cellpadding=0 cellspacing=0>
             <tr>
              <td class="whitebg" valign=top><font class=numerino>19</font></td>
              <td class="whitebg"><html:text property="qa019" styleId="qa019" style="width:80px;" onchange="datiModificati();" maxlength="4" /></td>
             </tr>
            </table>
           </td>
          </tr>
         </table>
        </td>
        <td>
         <table cellspacing=0 style="padding-right:1px;">
          <tr>
           <td class="whitebg" style="border: 1px dashed #00A160;">
            <table cellpadding=0 cellspacing=0>
             <tr>
              <td class="whitebg" valign=top><font class=numerino>20</font></td>
              <td class="whitebg"><html:text property="qa020" styleId="qa020" style="width:50px;" onchange="datiModificati();" maxlength="4" /></td>
             </tr>
            </table>
           </td>
          </tr>
         </table>
        </td>
       </tr>

Codice Javascript :
codice:
var formAJAX;
var comune;
var provincia;
var codCatasto;
var resultTable;


//window.onload = function () {
document.onkeypress = function (e) {

 	var kC = (window.event) ? event.keyCode : e.keyCode; // MSIE : Firefox
	var Esc = (window.event) ?	27 : e.DOM_VK_ESCAPE; // MSIE : Firefox
	if(kC==Esc) {
	
		if ( comune != null)
	    	comune.style.background='white';
	    if ( resultTable != null ) {
	    	comune.value = '';
	    	resultTable.style.display='none';
	    }

	}
	
}


  function inizializza(div, campoComune, campoPr, campoCod){
 		
   	resultTable = document.getElementById(div); //Tabella risultato

    alert("RESULT TABLE : " + resultTable);

    comune = document.getElementById(campoComune); //Campo Comune
    alert("comune : " + comune);
    provincia = document.getElementById(campoPr); //Campo Provincia
    alert("provincia : " + provincia);

    if(campoCod != null) {
		codCatasto = document.getElementById(campoCod); //Campo Codice Catasto
	} else {
		codCatasto = null;
	}  
	 

  if ( resultTable != null ) {
 		resultTable.style.display='none';
 		comune.value = '';
 		//alert('oooo'+resultTable);
 	}
  
  
   	setPosition();
}

function getX(obj)  
{   
    var curleft = 0;   
 
    if (obj.offsetParent)   
    {   
        while (obj.offsetParent)   
        {   
            curleft += obj.offsetLeft;   
            obj = obj.offsetParent;   
        }   
    }  
    else if (obj.x)   
    {  
        curleft += obj.x;   
    }  
    return curleft;   
}  
 
   
function getY(obj)  
{   
    var curtop = 0;   
      
    if (obj.offsetParent)   
    {   
        while (obj.offsetParent)   
        {   
            curtop += obj.offsetTop;   
            obj = obj.offsetParent;   
        }   
    }   
    else if (obj.y)   
    {  
        curtop += obj.y;   
        
          
    }  
    return curtop;   
}  

var addListener = function() {
    if ( window.addEventListener ) {
        return function(el, type, fn) {
            el.addEventListener(type, fn, false);
        };
    } else if ( window.attachEvent ) {
        return function(el, type, fn) {
            var f = function() {
                fn.call(el, window.event);
            };
            el.attachEvent('on'+type, f);
        };
    } else {
        return function(el, type, fn) {
            element['on'+type] = fn;
        }
    }
}();



 function removeListener(element,type,fcn)
{
  if (!element.removeEventListener && !element.detachEvent) return false;
  if (element.removeEventListener) element.removeEventListener(type,fcn,false);
  else if (element.detachEvent) element.detachEvent('on' + type,fcn);
  return true;
}

function setPosition() {
 	
   if (document.all)
      resultTable.style.top=getY(comune)+36;
   else
   	  resultTable.style.top=getY(comune)+22;
   resultTable.style.left=getX(comune);  
   resultTable.style.zIndex="1";
   addListener(comune, 'blur', focusPerso);

}

function completa() {

    setPosition();
    if (comune.value.length==0){
       comune.value='';
       provincia.value='';
       if(codCatasto!=null)
       	codCatasto.value='';
    }
    if (comune.value.length<2){
      comune.style.background='white';
      resultTable.style.display='none';
      return;
    }
   
    var url = "caricaListaComuni.do?comune=" + comune.value;
    req=initRequest();
    if(req) {
       req.onreadystatechange = processRequest;
       req.open("GET", url, true);
       req.send(null);
    }
}


function processRequest() {

    var checkingTown;

    if (req.readyState == 4) {
        if (req.status == 200) {
        	var xmldoc = req.responseXML;
           	var comuni = xmldoc.getElementsByTagName('comune');
            var table="<table>";
            
            
            for (var iNode = 0; iNode < comuni.length; iNode++) {

                     checkingTown = comuni[iNode].childNodes[1].firstChild.nodeValue;

                     table += "<tr id='riga"+iNode+"'>";
	            	 table += " <td id='cella1"+iNode+"' nowrap bgcolor='white' onmouseover=impostaColoreRiga("+iNode+",'white','blue'); onmouseout=impostaColoreRiga("+iNode+",'black','white');";
	      			 table += " onclick=\"imposta('" + comuni[iNode].childNodes[0].firstChild.nodeValue +"', '" + comuni[iNode].childNodes[1].firstChild.nodeValue + "', '" + comuni[iNode].childNodes[2].firstChild.nodeValue + "');\" >";
                     table += "" + comuni[iNode].childNodes[1].firstChild.nodeValue + "" ;
	      			 table += " (" + comuni[iNode].childNodes[0].firstChild.nodeValue + ") " ;
	      			 table += "</td>";
		   			 table += "</tr>";
		   			  
            }

            table += "</table>";

          resultTable.innerHTML = table;
          resultTable.style.display='';
          //Controllo lunghezza result
          if(comuni.length == 0){
            comune.style.background='red';
            provincia.value='';
            if(codCatasto!=null)
            	codCatasto.value='';
            alert('Nessuna corrispondenza trovata sulla base dati');
            return;
          }
          if(comuni.length == 1){
            imposta( comuni[0].childNodes[0].firstChild.nodeValue, comuni[0].childNodes[1].firstChild.nodeValue, comuni[0].childNodes[2].firstChild.nodeValue );
          }
          comune.style.background='white';
        } else {
          alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
}

 function initRequest() {
       if (window.XMLHttpRequest) {
           return new XMLHttpRequest();
       } else if (window.ActiveXObject) {
           isIE = true;
           return new ActiveXObject("Microsoft.XMLHTTP");
       }
   }



function focusPerso(){
  // if(inEdit()){
  //     comune.style.background='red';
  //     provincia.value='';
   //    codCatasto.value='';
  // }
   return true;
}

function inEdit(){
   if(comune.value!=compareField.value){
      return true;
   }
   if(dataField.value!=compareDataField.value){
      return true;
   }
   return false;
}






//imposta i campi al click della riga
function imposta(pr, cm, codCat){


   comune.value=cm;
   provincia.value=pr;
   if(codCatasto!=null)
  	 codCatasto.value=codCat;
   resultTable.style.display='none';
   comune.style.background='white';
   addListener(comune, 'blur', focusPerso);
}


//
function handlePopupOver() {
   removeListener(comune, 'blur', focusPerso);
}

function handlePopupOut(){
   if(resultTable.style.display == ''){
     addListener(comune, 'blur', focusPerso);
   }

}


//Imposta colori della riga selezionata dalla tab di risultati
function impostaColoreRiga(i,color,background){
   document.getElementById('cella1' + i).style.background=background;
   document.getElementById('cella1' + i).style.color=color;


}


Il problema nella creazione della pop up è che alcuni comuni hanno le vocali accentate e questo succede anche per gli apostrofi; visto che si utilizzano gli apostrofi sulla base dati per simulare gli accenti delle lettere mi viene alterata la chiamata a funzione imposta.

Qualche suggerimento diverso dall'escape di quel carattere che già son stati provati e riprovati, grz.