PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
tags where approriate when posting code. Read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I have a form with dynamic textboxes. The code is something like this:
Using this code I get some dynamic textboxes and later on I would like to retrive the values typed in these textboxes into a php file (using a submit button).
tags where approriate when posting code. Read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I would personally create a hidden var to be posted along with the form that holds the number of text boxes shown on the page - so update the value of it when you add the new text box. Then you can loop through all the values on the processing page for the text boxes.
function changeIt()
{
var a = document.form.quantitystd1.value;
for (i=1; i<a;i++){
my_div.innerHTML = my_div.innerHTML +"<br><input type='text' їb]name='mytext"+i+"'>"ї/b]}
my_div.innerHTML = my_div.innerHTML+"<br><input type='hidden' name='field' value="+a+">"
}
</script>
I have also added a hidden field to pass the number of the dynamic textboxes to the php file. It wouldn't work with array_key_exists("mytext$idx", $_POST), but it's working in this way! It wasn't necessay to use array_map().