how to generate new input fields based upon a text field value? |
[eluser]towki[/eluser]
Please see image. http://i47.tinypic.com/2qdxtox.png In my screen shot, you'll see I have created a text field asking for a number of victims and a submit button with the value "GO"(in the lower part red background). When a number of victims is entered and click the submit button "GO", on the same page(nothing will change except the addtional input fields) new input fields will be generated for each victim's data(e.g name,sex,age..) depending on the number of victims entered. So it would be like a one whole form to be submitted to the database when the "SAVE" button is clicked. Please give me examples, if possible in php, please Sorry for my english, I hope you got my point.
[eluser]solid9[/eluser]
You need to learn jQuery for this, http://www.mkyong.com/jquery/how-to-add-...th-jquery/
[eluser]towki[/eluser]
is this not possible in Php?? I have no knowledge of javascript
[eluser]solid9[/eluser]
It is possible in php. You can just use if and else with it. But it is easier and interactive to implement using jQuery. Here is a good tutorial in jQuery, http://net.tutsplus.com/articles/news/an...of-jquery/ Take the time to learn the tutorial, it is worth the time you spent learning it. I promise you, you will not regret it.
[eluser]towki[/eluser]
[quote author="solid9" date="1351321032"]You need to learn jQuery for this, http://www.mkyong.com/jquery/how-to-add-...th-jquery/ [/quote] I have tried to this to my code and it works fine but however when i click my SAVE button and the form doesnt send because of validation errors, the generated fields resets itself so the data which i have entered lately are gone. There is no problem in my own created fields because i managed this issue in my php code.
[eluser]Smalbach[/eluser]
is easy to do in PHP, tell me more about the form and I will help you. What language do you speak?
[eluser]towki[/eluser]
[quote author="Smalbach" date="1351392574"]is easy to do in PHP, tell me more about the form and I will help you. What language do you speak? [/quote] Filipino language
[eluser]towki[/eluser]
I think this example code is what i need, because its very simple just plain javascript. But im still confused how to get the values in each field generated by this code. Could anyone please use this code and give me an example in getting values of the generated fields then store it in a variable or insert in into the database. Please i'll try to understand.
[eluser]Smalbach[/eluser]
in php file1.php Code: <form action="file2.php" method="post" > file2.php Code: <?php you can integrate with codeigniter but I recommend you to do it with jquery, is more attractive @solounaverdad |
Welcome Guest, Not a member yet? Register Sign In |