This is really driving me nuts... ;)
I have a table an in each row a Delete button. Here is the Code:
while( $row=mysqli_fetch_row($result) ){
echo'<tr id="'.$row[0].'" >';
echo'<td id="colx">'.$row[1].'</td>';
echo'<td id="CellTextBeschreibung">'.$row[5].'</td>';
echo'<td id="CellTextLong">'.$row[3].'</td>';
echo'<td id="CellTextLat">'.$row[4].'</td>';
?>
<td><input type="button" onclick="ShowOnMap( <?php echo $row[0]; ?> )" value="Zeigen"></td>
<td ><?php echo( $row[6]); ?></td>
<td>
<FORM id='deleteform' action='delete.php' method='post'>
<INPUT type='hidden' name='mapid' value='<?php echo( $row[0]); ?>'>
<INPUT type='hidden' name='userid' value='<?php echo( $row[2]); ?>'>
<INPUT type='hidden' name='aktuuserid' value='<?php echo( $userID); ?>'>
<INPUT id='subdel' type='submit' OnClick="return confirm('Löschen.Bist Du sicher?');" value='Löschen'>
</FORM>
</td>
<td id="colx"> <?php echo( $row[7]); ?> </td>
<td id="colx"> <?php echo( $row[8]); ?> </td>
</tr>
<?php
}
I'm trying to cach the Submit Button (FORM) with this Jquery code:
$("#subdel").click( function() {
$.post( $("#deleteform").attr("action"), $("#deleteform").serializeArray(), function(info){alert(info); document.location.reload(true); });
$("#deleteform").submit( function() {
return false;
});
});
But it's not working... ... it loads the "delete.php" page and it is not returning to the origin page...
Although I have the SAME Code for SAVING (but not in a Table), this is not working...
I would appreciate any Help on this... Thank you in advance... :)
p.s.: Here is the working SAVE Function:
<FORM id='eingabeform' action='save.php' method='post'>
<INPUT type='hidden' name='userid' value='<?php echo( $userID); ?>'>
<INPUT type='hidden' name='username' value='<?php echo( $aktuuser); ?>'>
<INPUT type='hidden' id='inputicon' name='icon' value='1'>
<INPUT type='hidden' id ='long' name='long' maxlength='20' >
<INPUT type='hidden' id ='lat' name='lat' maxlength='20' >
<div>Beschreibung: <INPUT type='text' id ='longlattext' name='longlattext' maxlength='300' ></div>
<div>Link (bei Bearf):<INPUT type='text' id ='link' name='link' maxlength='300' ></div>
<br>
<INPUT id='submit' type='submit' value='Speichern'> <INPUT id='abbrechen' type='Button' value='Schließen' onclick="Hide('Lmenuinput')">
</FORM>
and the associated Jquery code:
$("#submit").click( function() {
$.post( $("#eingabeform").attr("action"), $("#eingabeform").serializeArray(), function(info){alert(info); if (!info=="Du musst auf der Karte einen Punkt anklicken" || !info=="Das ist kein Link! Check das bitte mal, ThX.. ;)") {document.location.reload(true); }});
$("#eingabeform").submit( function() {
return false;
});
});
As you can see, it's identical... and this one is working... the only difference is, that the above DELETE FORM is multiplied within the table, the SAVE FORM not... could that be related to this error??
here is the delete.php:
<?php
include 'DBconn.php';
// ******* TabelleKopf speichern *****************************
$sql="DELETE FROM `map` WHERE mapID=".$_POST[mapid];
if (!mysqli_query($con,$sql))
{
die('Fail: ' . mysqli_error($con));
}
echo "Success";
mysqli_close($con);
}
?>