Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to POST dynamic input tags in codeigniter
    primarykey
    data
    text
    <p>I am facing a serious dilemma, and wondering how this would be possible. I have a form built in codeigniter framework. At the end of the form is an input tag which takes a number and appends a new form with exact rows of input tags as the value of the last input tag. I have done this using javascript, code is </p> <pre><code>$('#formName9').on('change', function() { var selected = $(this).val(); $('#subForm').empty(); $("#subForm").append('&lt;table border="" style="border:none; background:#f2f2f1; margin-bottom:10px; border-collapse: collapse; margin-top: 25px; box-shadow: 9px 4px 8px rgba(50, 50, 50, 0.75);" cellspacing="0" cellpadding="0"&gt; &lt;tr&gt; &lt;td style="text-align: center; width: 30px; border-width: 0px;"&gt;&lt;img src="&lt;?php echo base_url(); ?&gt;assets/img/icon_house.png" &gt;&lt;/td&gt; &lt;td style="text-align: center; border-width: 0px;"&gt;&lt;img src="&lt;?php echo base_url(); ?&gt;assets/img/table_divider.png" /&gt;&lt;/td&gt; &lt;td style="text-align: center; width: 200px; border-width: 0px;"&gt;&lt;strong&gt;Unit Name&lt;/strong&gt;&lt;/td&gt; &lt;td style="text-align: center; border-width: 0px;"&gt;&lt;img src="&lt;?php echo base_url(); ?&gt;assets/img/table_divider.png" /&gt;&lt;/td&gt; &lt;td style="text-align: center; width: 250px; border-width: 0px;" &gt;&lt;strong&gt;Owner Name&lt;/strong&gt;&lt;/td&gt; &lt;td style="text-align: center; border-width: 0px;"&gt;&lt;img src="&lt;?php echo base_url(); ?&gt;assets/img/table_divider.png" /&gt;&lt;/td&gt; &lt;td style="text-align: center;width: 150px; border-width: 0px;"&gt;&lt;strong&gt;Owner Salutation&lt;/strong&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;'); for (var i=1; i&lt;=selected; i++) { $('#subForm').append('&lt;div style="float: left; padding-left: 13px; padding-right: 12px; padding-top: 7px; margin-top: 0px;"&gt;'+i+'&lt;/div&gt;&lt;input type="text" name="unitName" id="unitName'+i+'" style="width:189px;" required /&gt;&lt;input type="text" name="ownerName'+i+'" id="ownerName'+i+'" style="width:241px;" /&gt;&lt;input type="text" name="salutation'+i+'" id="salutation'+i+'" style="width:137px;" /&gt;&lt;br /&gt;'); } }); </code></pre> <p>you can see i have used different naming conventions for all the appended tags according to the loop.</p> <p>Now these values need to be posted in order for the PHP[SERVER] to do further work, but how will i post these dynamic values? i have tried to the following, but this just hangs my local server and doesn't go any further</p> <pre><code>$ownerName = array(); for ($i=0; $i&lt;=$blockUnits ; $i+1) { $ownerName[$i] = "ownerName".$i; $this-&gt;input-&gt;post('ownerName[$i]'); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload