Getting A Value From Dynamically Created Textbox Through Php March 31, 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 JugaHow To Make A Link Open In New Tab As Well As Redirect In CurrentHow To Pass Parameters In Android Phonegap ApplicationForm Character Encoding Problems With Special Characters<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 postsCheckbox With Array Inside Looping False Result?Count Number Of Mysql RowsPerform Post Method On Current PagePassing Data To Another Page After Form Submit With Php 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"