lundi 30 mars 2015

CodeIgniter from

I have to submit my codeIgniter form which have dynamic columns. how can I get them from controller using a loop.


this is my view page



<?php echo form_open_multipart('main_controller/do_insert');?>
<div id="mainDiv">
<div><input type="text" name="name0"/></div>
<div><input type="file" name="img0"/></div>
</div>
<input type="button" value="add an entry" onClick="add('0')">
<input type="submit" value="save all"/>
<?php from_close();?>

<script>
function add(x)
{
var count=x;count++;
var str1="<div><input type='text' name='name"+count+"'/></div>"
var str2="<div><input type='file' name='img"+count+"'/></div>"
var str3="<input type='button' value='add an entry' onClick='add(`1`)'>";
$("#mainDiv").append(str1+str2+str3);
}
</script>


note: the value of 'x' may not work properly but its not relevant here, can fix it by a global variable.


My problem is that how can i code controller for getting all the values including images and save them to table, while submitting the form.


Aucun commentaire:

Enregistrer un commentaire