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

[eluser]Smalbach[/eluser]
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


Messages In This Thread
how to generate new input fields based upon a text field value? - by El Forum - 10-28-2012, 07:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB