Getting A Value From Dynamically Created Textbox Through Php July 27, 2023 Post a Comment I have n number of text box (n may be any number) with same name. And I want to access the value of all the text box of that name. Ex-: Solution 1: <script>jQuery(document).ready(function($) { $('#newFieldBtn').click(function(){ var count = document.getElementById('count').value; count++; var code = '<input type="text" name="user'+count+'" />'; jQuery('#create').append(code); document.getElementById('count').value = count; </script>Copyand your html like...<form method="post"id="create"> <input type="hidden"id="count" value="0" name="count"> <input type="button"id="newFieldBtn"/> <input type="submit" name="save" value="save"/> </form> Copyand in your php code... <?phpif(isset($_POST)) { $count = $_POST['count']; for($i=1;$i<=$count;$i++) { $user.$i = $_POST['user'.$i]; } } ?>CopySolution 2: Try this one, it will show you the values :Baca JugaLocalhost/test.php Returns NothingTrouble With If Statement PhpHow To Replace Img Src And Link Href In A Document With A Mustache Expression?<formaction="#"method="post"><inputtype="text"name="user[]" /><inputtype="text"name="user[]" /><inputtype="text"name="user[]" /><inputtype="submit"value="submit" ></form><?phpif ($_SERVER['REQUEST_METHOD'] == 'POST') { foreach($_POST['user'] as$key => $value) { echo$key." has the value = ". $value."<br>"; } } ?>CopySee this in action: http://wistudat.be/try/array.php Share You may like these postsHow To Upload File Using PhpUse Anchor After Post Form SubmissionWhy Does My Footer Bar Disappear When My Php Contact Form Is Sent Successfully?How To Add Category(posts) In Wordpress Single Post Post a Comment for "Getting A Value From Dynamically Created Textbox Through Php"
Post a Comment for "Getting A Value From Dynamically Created Textbox Through Php"