Getting A Value From Dynamically Created Textbox Through Php February 26, 2024 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 JugaPhp - Domdocument - Need To Change/replace An Existing Html Tag W/ A New OneAfter Being Returned By My Factory Service, Data Is Displaying With Visible Html TagsWebsite Fit On Screen For Tablets, Viewport Not Working?<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 posts Javascript Not Submitting Hidden Form When Clicking TextPhp Page Navigation Using Arrays And Foreach, Trouble With Category Level = ActiveMysql Insert Submit Button PhpHtml Email Sent Via Php Treated As Spam In Gmail 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"