Ciao a tutti,
scudate forse la banalità, ma non sono espertissimo di javascript
ho il seguente problema:
ho una tabella generata dinamicamente da asp e oracle che può avere da una ad xx righe. Per ogni riga ho una cella con un div con un nome che è prenoStatus1, prenoStatus2, prenoStatus3 e così via tanti div quante sono le rige.
Poi ho su ogni riga anche un tasto che mi richiama una funziona Ajax che dovrebbe riempirmi il div di cui sopra, chiaramente alla riga corrispondente.
Allo script in ajax passo il contatore del div e lo associo all'id del div che è sempre lo stesso ma poi quando lo piazzo nel getElementbyID come variabile non funziona. Se metto nel getElementbyID il nome di un ID specifico di un div funziona, ma chiaramente mi carica i dati da ajax sempre nella stessa riga.
vi metto il codice:
var XMLHTTP;
function RichiestaPrenoAJAX(stringa,stringa1,stringa2,strin ga3,stringa4,stringa5)
{
if (stringa.length > 0)
{
var identificaDiv = "prenoStatus" + stringa5; ### qui identifico il div che mi serve stringa5 non è altro che un numero quindi identificaDiv può diventare ad es. prenoStatus3 ###
var url = "anagraficheProduzioneAjax.asp?id_master_correlato =" + stringa + "&memotype=" + stringa1 + "&nome=" + stringa2 + "&dal=" + stringa3 + "&al=" + stringa4 + "&idM=" + stringa + "&aziendaM=" + stringa2;
XMLHTTP = QualeBrowser(GestioneStato);
XMLHTTP.open("GET", url, true);
XMLHTTP.send(null);
}
else
{
document.getElementById(identificaDIV).innerHTML = "";
}
}
function GestioneStato()
{
if (XMLHTTP.readyState == 4)
{
var R = document.getElementById(identificaDIV); ### qui dovrebbe prendermi il valore dell id quindi es prenoStatus3 e sotto con innerHTML dovrebbe spararmi il contenuto della richiesta XML del div giusto, ma che non funziona ###
R.innerHTML = XMLHTTP.responseText;
}
}
function QualeBrowser(QualeBrowser)
{
if (navigator.userAgent.indexOf("MSIE") != (-1))
{
var Classe = "Msxml2.XMLHTTP";
if (navigator.appVersion.indexOf("MSIE 5.5") != (-1));
{
Classe = "Microsoft.XMLHTTP";
}
try
{
OggettoXMLHTTP = new ActiveXObject(Classe);
OggettoXMLHTTP.onreadystatechange = QualeBrowser;
return OggettoXMLHTTP;
}
catch(e)
{
alert("Errore: l'ActiveX non verrà eseguito!");
}
}
else if (navigator.userAgent.indexOf("Mozilla") != (-1))
{
OggettoXMLHTTP = new XMLHttpRequest();
OggettoXMLHTTP.onload = QualeBrowser;
OggettoXMLHTTP.onerror = QualeBrowser;
return OggettoXMLHTTP;
}
else
{
alert("L'esempio non funziona con altri browser!");
}
}
Grazie a tutti per l'aiuto che potrete darmi
Saluti
Stefano