<script type="text/javascript">
function pdf() {
document.form.action = "pdf.php";
document.form.target = "_blank";
}
try {
req = new XMLHttpRequest();
} catch (e) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e){
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed){
req = null;
}
}
}
function checkInput() {
req.open("GET", 'check.php?name=' + document.form.name.value, true);
req.onreadystatechange = function() {
switch(req.readyState) {
case 4:
if(req.status!=200) {
alert("Fehler:"+req.status);
} else {
if(req.responseText == "1") {
document.form.action = "send.php";
document.form.target = "_self";
} else {
alert("Bitte vorerst das PDF erstellen! ");
}
}
break;
default:
return false;
break;
}
};
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.send(null);
return false; // wichtig, damit das Formular nicht abgesendet wird
}
</script>
<form name="form" action="" method="post" target="">
<input ... />
<input ... />
<input ... />
<input name="PDF" type="submit" value="PDF erstellen" onclick="javascript:pdf();" />
<input name="submit" type="submit" value="senden" onclick="return checkInput();" />
</form>