Kiong Lam Kiong Lam - 2 days ago 4x
Javascript Question

cloning DatePicker using html() not work #duplicate

i already try to search google...and read some question from stackoverflow,
like this and this etc..

but i still confuse to resolve my problem..

<table class="table noborder table-striped table-bordered">

<tr id="rows0">
<td id="kolom1">
<input type='text' name="nobukti" class="form-control nobukti" maxlength="15"/>
<td id="kolom2">
<input type='text'class="form-control tanggal" name="tanggal" maxlength="12" style="width: 100px" />
<td id="kolom3">
<input type='text' name="noref" class="form-control" maxlength="20"/>
<td id="kolom4">
<input type='text' class="form-control numeric" name="tempo" maxlength="3" style="width: 50px"/>
<td id="kolom5">
<input type='text' class="form-control onlynumber price" name="amount" value="0,00" maxlength="10"/>
<td id="kolom6">
<select name="dt" class="form-control" style="width: 30px">
<option value="K">K</option>
<option value="D">D</option>
<td id="kolom7">
<input type='text' class="form-control" name="description" maxlength="255"/>
<td id="buttonMinusAdd">
<input type="button" onClick="addbaris(0);" name="addRow" class="add addRow btn btn-success" value="+" style="min-width: 30px !important; padding: 3px 0px;" />



and this.

$('.tanggal').datepicker({ autoSize: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd/mm/yy'
$(".tanggal").datepicker("setDate", new Date());

function addbaris(x){
var kolom1 = $("#kolom1").html();
var kolom2 = $("#kolom2").html();
var kolom3 = $("#kolom3").html();
var kolom4 = $("#kolom4").html();
var kolom5 = $("#kolom5").html();
var kolom6 = $("#kolom6").html();
var kolom7 = $("#kolom7").html();

var withoutButton = "<tr id='rows"+x+"'>" +
"<td>"+kolom1+"</td> " +
"<td>"+kolom2+"</td> " +
"<td>"+kolom3+"</td> " +
"<td>"+kolom4+"</td> " +
"<td>"+kolom5+"</td> " +
"<td>"+kolom6+"</td> " +
"<td>"+kolom7+"</td> ";

var kolom8 = "<td><input type='button' onClick='addbaris("+x+");' name='addRow' class='add addRow btn btn-success' value='+' style='min-width: 30px !important; padding: 3px 0px;'/> \n";
kolom8 = kolom8 +"<input type='button' onClick='minbaris("+x+");' name='remRow' class='redbtn remRow btn btn-danger' value='-' style='min-width: 30px !important; padding: 3px 0px;'/></td></tr>";

withoutButton = withoutButton + kolom8;

$('.table tr:last').after(withoutButton);


function minbaris(x){

i am using html(). then add to table with this
$('.table tr:last').after(withoutButton);

i need to clone a rows every click button


you just need add this line



$('.table tr:last').after(withoutButton);

hope it will help you