Ciao a tutti.
Ho un problema che non riesco a risolvere ma soprattutto a capire la causa.
All'invio del form postato di seguito dovrebbe visualizzarsi la classica immagine `Please wait`, invece quando invio il form prima si attiva la alert 'The server script has now completed' e quando clicco su `ok` si apre la pagina che processa i dati lato server.
Nell'onsubmit del form ho previsto la funzione di controllo `atLeastOneChecked` che quando è soddisfatta dovrebbe richiamare la funzione `longcall();`.
Questo accade ma non come mi aspettavo... potete darmi un suggerimento?
Grazie mille!
codice:
<html>
<head>
<meta http-equiv="Content-Language" content="it">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Test</title>
<script language="javascript" type="text/javascript">
// <!CDATA[
function loadXMLDoc()
{
try {
req = new XMLHttpRequest();
} catch (err1)
{
try {
req = new ActiveXObject("Msxml12.XMLHTTP");
} catch (err2)
{
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (err3)
{
req = false;
}
}
}
return req;
}
var http = loadXMLDoc()
function handleHttpResponse() {
if (http.readyState == 4 && http.status==200) {
document.getElementById('wait').style.visibility = "hidden";
alert('The server script has now completed');
} else {
document.getElementById('wait').style.visibility = "visible";
}
}
function longcall() {
myRand=parseInt(Math.random()*999999);
http.open("POST","_inc_upd.asp",true);
http.onreadystatechange = handleHttpResponse;
http.send();
}
function PopUp() {
var w = 500;
var h = 300;
var l = Math.floor((screen.width-w)/2);
var t = Math.floor((screen.height-h)/2);
finestra=window.open('_inc_pagina_commento.asp','','width=' + w + ',height='+ h + ',top=' + t + ',left=' + l+',scrollbars=no,menubar=no,toolbar=no,status=no');
}
function atLeastOneChecked(form) {
var inputs = form.getElementsByTagName('input');
var i = inputs.length;
while (i--) {
if(inputs[i].checked && !inputs[i].disabled)
if(confirm("Confermi?.")) {
PopUp();
return false;
} else {
longcall();
return true;
}
}
alert("Stop!")
return false;
}
// ]]>
</script>
...
<form name=frmTest action="_inc_upd.asp" method=POST onsubmit="return atLeastOneChecked(this)">
<input type=checkbox name=chkParent25 value=21118>
</p>
<input type=checkbox name=chkParent26 value=21119>
</p>
<input type="image" src="/images/assegnazione_button.gif" border="0"></p>
</form>
<div id="wait" style="background-color:white;position:absolute;top:240px;left:360px;width:70px;height:50px;visibility:hidden;border: 1px solid black;padding:20px;">
[img]/images/ajax-loader.gif[/img]
Please wait...
</div>
...