Welcome Guest, Not a member yet? Register   Sign In
how to generate new input fields based upon a text field value?
#11

[eluser]towki[/eluser]
[quote author="Smalbach" date="1351434793"]in php
file1.php
Code:
<form action="file2.php" method="post" >

amount of fields

<!--type the amount of field that you want to display in the nest form -->

<input type="text" name="amount">
<input type="submit" value="Generate">


</form>

file2.php

Code:
<?php

//get te parameter
$amount=$_POST['amount'];

//make a cycle
echo "<form action='other_file'>";
for($i=0;$i<$amount;$i++){
?&gt;
<br>
field &lt;?php echo ($i+1) ?&gt;
&lt;input type="text" name="field_name&lt;?php echo $i ?&gt;"&gt;



&lt;?php
}

echo "&lt;/form&gt;"
?&gt;

you can integrate with codeigniter
but I recommend you to do it with jquery, is more attractive

@solounaverdad[/quote]

But i have only one file, i mean one view only in codeigniter where there is only one form but two submit buttons, one functions as generating fields and the other one function as saving all the data to a database. See my screen shot
#12

[eluser]Smalbach[/eluser]
this is one example that i found searching in google
whit jquery

http://charlie.griefer.com/blog/2009/09/...-elements/

you can see the documentation

http://api.jquery.com/append/

You should learn javascript jquery





Theme © iAndrew 2016 - Forum software by © MyBB