[英]Javascript on Blade View Laravel Append Row
Hello i want ask you and hope find the answer of my problem here 你好,我想问你,希望在这里找到我的问题的答案
This is My JS in blade view Laravel (i've change a little from CI) 这是刀片视图Laravel中的My JS(我对CI进行了一些更改)
$(document).ready(function(){
var i = <?php echo $count ?> //var i = '2'; only for try
$('#datetime').datepicker({
dateFormat: "yy/mm/dd"
});
$('#add').click(function(){
i++;
$('#tbanalisa tbody').append("<tr>"+"<td>"+i+"</td>"+"<td><textarea class=\"form-control\" rows=\"3\" name=\"analisa"+i+"\" placeholder=\"Analisa Penyebab\" style=\"resize: none; height: 50px\"></textarea></td>"+"<td><textarea class=\"form-control\" rows=\"3\" name=\"tindakan"+i+"\" placeholder=\"Tindakan Perbaikan dan Pencegahan\" Analisa Penyebab\" style=\"resize: none; height: 50px\"></textarea></td>"+"<td><input class=\"form-control\" type=\"text\" name=\"pic"+i+"\" placeholder=\"PIC\"></td>"+"<td><input class=\"form-control\" type=\"text\" name=\"tanggal_pelaksanaan"+i+"\" id=\"time"+i+"\" ></td>"+"</tr>");
document.getElementById('count').value = i;
});
});
Here is My Blade View (Laravel) 这是我的刀片视图(Laravel)
<tbody>
@php
$x = 1;
@endphp
<tr>
<td><?php echo $x ?></td>
<td><textarea class="form-control" rows="3" name="<?php echo "analisa".$x ?>" placeholder="Analisa Penyebab" style="resize: none;
height: 50px"></textarea></td>
<td><textarea class="form-control" rows="3" name="<?php echo "tindakan".$x ?>" placeholder="Tindakan Perbaikan dan Pencegahan"
style="resize: none;
height: 50px"></textarea></td>
<td><input class="form-control" type="text" name="<?php echo "pic".$x ?>" placeholder="PIC"></td>
@php
$x++;
@endphp
</tbody>
Try replacing 尝试更换
var i = <?php echo $count ?>;
with 同
var i = {{ $count }};
If that doesn't work, post any Laravel/php/server errors you're receiving in your logs, etc. 如果这样不起作用,请在日志中张贴您收到的任何Laravel / php / server错误,等等。
您将要附加的所有输入都应该在一行中。
append("<tr>"+"<td>"+i+"</td>"+"<td><textarea class=\"form-control\" rows=\"3\" name=\"analisa"+......"</tr>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.