This question already has an answer here:
I tried to add a form from a php file to another php file using jQuery, and I added an event to my added input(submit) button, but it's nt work,
I have seen some answers that propose using the method $elm.on("click",function()
instead of of $elm.click(function()
, but it still not work.
So here is my code :
<div id="update" class="third">
<div class="updatingzone">
You will have to rwrite all the data again
<form method="post" class="updating">
<input type="text" name="id" class="id" style="width:40px;" />
<input type="submit" id="button" value="Insert" />
</form>
<input type="submit" id="button" class="cancel" value="Cancel" />
</div>
<div class="insertion"></div>
</div>
when I press the Button Insert this php file is added :
<?php require_once "connexion.php";
$gdb = new GestionBD();
$id = $_POST["id"];
$req = "select * from utilisateurs WHERE id='$id'";
$results = $gdb->selectFromBD($req);
foreach ($results as $result):
?>
<form class="insertMode" method="post">
<input type="text" value="<?php echo $result->nom;?>" class="nom" name="nom" /><br />
<input type="text" value="<?php echo $result->email;?>" class="email" name="email" /><br />
<input type="text" value="<?php echo $result->sexe;?>" class="sexe" name="sexe" /><br />
<input type="text" value="<?php echo $result->age;?>" class="age" name="age" /><br />
<input class="test" id="button" type="submit" value="Add" />
</form>
<?php endforeach;?>
When I press the button with the class test I don't get an alert with "no" message, as you can see in the script :
$(".updating").submit(function () {
var id = $(".id").val()
$(".insertion").show()
$.post("getId.php",{id:id},function (data) {
$(".insertion").html(data)
});
return false;
});
$(".test").click(function () {
alert("no");
});
And i am sorry if this is long.. Thank you people
</div>