Ciao a tutti. Ho un problema con uno script ajax.
Ho un pagina in asp che mi stampa tutte le fatture. In fondo ad ogni riga ci metto un'immagine diversa a seconda che la fattua sia pagata o meno. Cliccando sull'immagine appare un checkbox, che chekkato mi fa passare da fattura pagata a fattura da pagare e viceversa. Il checkbox mi fa partire un httprequest che mi esegue l'update e mi cambia l'immagine pagata/da pagare.
Il problema è che a volte funziona ed a volte no. Ogni fattura ha un indice cont, e a volte mi passa l'indice del checkbox che ho selezionato precedentemente. Vi posto il codice della pagina asp

codice:
<%
str = "SELECT * from e_scadenziario WHERE year(data_scadenza)>" & (year(date)-1) & " ORDER BY data_scadenza DESC"
%>

<%
Set objRs = Server.CreateObject("ADODB.Recordset")
set objRs = objConn.Execute(str)
paridispari = 1
c = 1
If not objRs.EOF then
response.write "<table align=center width=100% cellspacing=1 cellpadding=2 bgcolor=#ffffff>"
	response.write "<tr class=""dieci"" align=""center"">"
	response.write "<td>data scadenza | fattura</td>"
	response.write "<td>rif</td>"
	response.write "<td>tot fattura</td>"
	response.write "<td>P</td>"
	response.write "</tr>"
	Do while NOT objRs.EOF
		c = c + 1
		paridispari = paridispari + 1
		If paridispari mod 2 = 0 then
			bgalterna = "#FFFFFF"
		Else
			bgalterna = "#E1F1FF"
		End If
		np_visa = objRs("num_prog")
		np_visa = quattro_cifre(np_visa)
		np_visa = Right(objRs("data_fattura"),2) & "-" & np_visa
		response.write "<tr bgcolor=" & bgalterna & ">"
		response.write "<td valign=top align=right class=undici width=60>"
		response.write sdata(objRs("data_scadenza"),"v")
		response.write "
"
		response.write sdata(objRs("data_fattura"),"v")
		response.write "</td>"
		response.write "<td valign=top align=right class=undici width=80>"
		response.write objRs("n_fatt_fornitore")
		response.write "</td>"
		response.write "<td valign=top align=center class=undici width=20>"
		If objRs("status") then
			chi = "i_ok.gif"
			ch = "pagata"
			chstato = "0"
			chchk = " checked"
		Else
			chi = "i_dollaro.gif"
			ch = "non pagata"
			chstato = "-1"
			chchk = ""
			'totale pagina visualizzata
			totpagina = totpagina + totfattura
		End If
		%>
			<div id="immagine<%=c%>"><%="<img src=image/" & chi & " alt='" & ch & "' width=16 height=16 border=0>"%></div>
			<DIV ID="azzstatus<%=c%>" STYLE="display:none;">
				<input type="Checkbox"<%=chchk%> id="check<%=c%>" onclick="request(<%=objRs("id")%>,<%=chstato%>,<%=c%>);">
			</DIV>
		<%
		response.write "</td>"
		response.write "</form>"
		response.write "</tr>"
	objRs.Movenext
	Loop

	response.write "</table>"

Else
	response.write "<table align=center cellspacing=1 cellpadding=10 bgcolor=#ffffff width='100%'>"
	response.write "<tr>"
	response.write "<td valign=top align=center bgcolor=#E1F1FF class=undici>"
	response.write "nessuna fattura da visualizzare"
	response.write "</td>"
	response.write "</tr>"
	response.write "</table>"
End If

objRs.Close
Set objRs = Nothing
%>
			</table>
Questa è la pagina request per l'ajax
codice:
var XMLHTTP;
var stato;
var idf;
var cont;

function request(id_fatt,status,c)
{
	XMLHTTP=GetXmlHttpObject();
	if (XMLHTTP==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	} 
	var url = "amm_scad_status.asp?status_id=" + id_fatt + "&status_onoff=" + status + "&c=" + c;
	cont=c;
	stato = status;
	idf=id_fatt;
	XMLHTTP.onreadystatechange=stateChanged;
	XMLHTTP.open("GET", url, true);
	XMLHTTP.send(null);
}

function stateChanged() 
{
	if (XMLHTTP.readyState == 4)
    {
		if (stato == -1){
			document.getElementById("immagine" + cont).innerHTML= "[img]image/i_ok.gif[/img]";
			document.getElementById("check" + cont).onclick = function(){request(idf,0,cont);}
		}else{
			if (stato == 0){
				document.getElementById("immagine" + cont).innerHTML= "[img]image/i_dollaro.gif[/img]";
				document.getElementById("check" + cont).onclick = function(){request(idf,-1,cont);}
			}
		}
    }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
mentre la pagina amm_scad_status.asp contiene solo un update

Spero in qualcuno.

tks