codeigniter - HTML button loop -
hello guys i'm trying figure out how can add more textboxes clicking add button.
i'm using codeigniter framework here view:
<form action="save_new_inventorytype" method="post"> <fieldset> <legend>add new inventory type</legend> <label id="lbl_tablename" name="lbl_tablename">inventory type name:</label> <input type="text" id="txt_tablename" name="txt_tablename" size="30" /><br> <label id="lbl_columns" name="lbl_columns" style="position: absolute; top: 276px;">column name:</label> <label style="position: absolute; top: 276px; left: 352px;">type:</label> <label style="position: absolute; top: 276px; left: 565px;">length/values:</label><br> <br> <input type="text" id="txt_columnname" name="txt_columnname" size="30"/> <select id="cbo_columntype" name="cbo_columntype" style="width: 200px;"> <option>int</option> <option>varchar</option> <option>text</option> <option>date</option> </select> <input type="text" id="txt_columnlength" name="txt_columnlength" size="30"/> <button type="button" class="btn_plusvalue btn-success btn-sm"><span class="glyphicon glyphicon-plus"></span></button><br> <br> <button type="button" class="btn_addtable btn-success btn-sm" id="btn_addtable" name="btn_addtable">save inventory type</button> <button type="button" class="btn_canceltable btn-danger btn-sm">cancel</button> <button type="button" class="btn_cleartable btn-warning btn-sm">clear</button> </fieldset> </form>
here print screen of view: want have three(textbox,combobox,textbox) duplicate when click on plus button. can me on one? please? know have use loop don't know how.
i have jquery
solution adding textbox on click of button. try this:
suppose, have form , button like:
<form> <input type="button" value="add textbox" name="add" id="add"/> </form>
then use append
method in script
tags:
var r; $(function(){ $('#add').on('click',function(){ for(var i=0;i<10;i++){ r= $('<input type="text" value="textbox" id="i"/>'); } $("form").append(r); }); });
here, <input type="text" value="textbox"/>
taken variable , appended
form
.
hi, here wanted.
Comments
Post a Comment