//imposto l'oggetto per la chiamata ajax
function objAjx(){
var ajax = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
ajax = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
ajax = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
ajax = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else{
return false
}
return ajax
}
//funzione chiamata ajax
function RequestAjaxNumeroPreventivo(dati){
//alert('+div+' '+dati)
ajx = objAjx();
if(ajx){
ajx.open('GET', "QueryJsonNumeroPreventivo.asp?q="+dati+"&noCache="+ Math.floor(Math.random() * (9999)), true)
ajx.send(null)
//verifico il cambio distato
ajx.onreadystatechange=function(){
//verifico quando lo stato e 4 (risposta del server)
if (ajx.readyState == 4 && ajx.status==200){
//creo array dati
var dati = JSON.parse(ajx.responseText)
//popolo il form separando i dati josn
document.getElementById('NomeCliente').value= dati[0].NomeCliente
document.getElementById('gara').value= dati[0].Gara
document.getElementById('NumeroPreventivo').value= dati[0].NumeroPreventivo
document.getElementById('DescrizioneLavori').value= dati[0].DescrizioneLavori
document.getElementById('DescrizioneLavorix').innerHTML= '<input name="submit" id="submit7" type="submit" value="Riepilogo Costi" onclick="this.form.action=(/RiepilogoCosti-Add.asp?cod=56&MODIFICA=SI/);" /> ' + dati[0].productID + 's'
}
}
}
}