1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| function envoie()
{
var nom=document.ajgroup.txtnom.value;
var style=document.ajgroup.txtstyle.value;
var histoire=document.ajgroup.txthist.value;
if (nom=="" || style=="" || histoire=="")
{
if(nom=="")
{
alert('Veuillez entrer un nom');
return false;
}
else if (style=="")
{
alert('Veuillez entrer le style');
return false;
}
else if (histoire=="")
{
alert ('Veuillez entrer l\'histoire du groupe');
return false;
}
}
else if (nom!="" || style!="" || histoire!="")
{
var xhr;
var data="nom=" + nom +"&style=" + style+"&histoire=" + histoire;
try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
catch (e)
{
try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
catch (e2)
{
try { xhr = new XMLHttpRequest(); }
catch (e3) { xhr = false; }
}
}
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{
if(xhr.status == 200)
document.getElementById("tabgroup").innerHTML =xhr.responseText;
else
document.getElementById("tabgroup").innerHTML="Error code " + xhr.status;
}
};
xhr.open( "POST", "ajoutgroup.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
return true;
}
} |
Partager