Hallo brauch mal eure Hilfe.
Ich habe eine ajax jQuery Funktion in meinem Script zum nachladen #
von Formulardaten und ich eine Funktion zum prüffen des Formulars.
Beides wird auch angesprochen und durchlaufen aber dennoch wird das Formular gesendet wenn die prüffung false ergibt.
Kann mir einer bei dem Problem helfen?
Die Formularseite:
Inhalt der nachladen.php
Danke Euch und Gruß
Hard
Ich habe eine ajax jQuery Funktion in meinem Script zum nachladen #
von Formulardaten und ich eine Funktion zum prüffen des Formulars.
Beides wird auch angesprochen und durchlaufen aber dennoch wird das Formular gesendet wenn die prüffung false ergibt.
Kann mir einer bei dem Problem helfen?
Die Formularseite:
HTML:
<html>
<head>
<title>Testseite</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="jquery-2.2.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
function ChkProfile() {
for (var i=0;i<document.mForm.length;i++){
if (document.mForm.Profile[i].checked==true){
var aa = document.mForm.Profile[i].value;
$.ajax({
type: "GET",
url: "nachladen.php?PID="+aa,
data: "nachladen",
success: function(nachladen){
$('#nachladen').empty();
$('<span>'+nachladen+'</span>').appendTo('#nachladen');
}
});
}
}
}
function ChkFormular() {
if (document.mForm.Farbe.value == "") {
alert("Bitte geben Sie an welche Verglasung Sie möchten");
document.mForm.Farbe.focus();
return false;
}
}
</script>
</head>
<body>
<Form name="mForm" action="" method="GET" onsubmit="return ChkFormular()">
<input name="Profile" type="radio" value="3" id="Profile" onclick="ChkProfile()">Profile 1
<input name="Profile" type="radio" value="4" id="Profile" onclick="ChkProfile()">Profile 2
<div id="nachladen"></div>
<br><br>
<input type="submit" value=" Absenden" ><br />
<br /><br />
</form>
</body>
</html>
Inhalt der nachladen.php
PHP:
if (isset($_GET["PID"])) {
$PID = $_GET["PID"];
$Farben = '<input name="Farbe" type="radio" value="2" /> weis<br>
<input name="Farbe" type="radio" value="3" /> rot<br>
<br><br> ';
echo $Farben;
}
Danke Euch und Gruß
Hard