<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.submit();
} else {
alert("Datei " + document.form.name.value + ".pdf existiert nicht!\r\nSie müßen erst 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="send.php" method="post">
<input ... />
<input ... />
<input ... />
<input name="PDF" type="submit" value="PDF erstellen" onclick="javascript:pdf();" />
<input name="senden" type="submit" value="senden" onclick="return checkInput();" />
</form>