您好我需要您的帮助我有这个代码,它添加了一个包含4个单元格的新列,但我的问题是如果我添加另一行如何实现列而不是5个单元格等等。< / p>
<script type="text/javascript">
var i = 1;
$(document).ready(function(){
$("#add_column").click(function (){
var trow;
var columnContent = ['<input type="text" name="options'+ i +'" value="{{ old('options. + p +') }}" class="form-control" placeholder="COl ' + i +' ">', '<input type="radio" name="col_nr['+ i +']" value="1" class="col1" >', '<input type="radio" name="col_nr['+ i +']" value="2" class="col1" >', '<input type="radio" name="col_nr['+ i +']" value="3" class="col1" >', '<input type="radio" name="col_nr['+ i +']" value="4" class="col1" >'];
for(var i=0; i<columnContent.length; i++){
if(i==0){
$('.optionsForm ').find('tr:eq(' + i + ')').append('<th>' + columnContent[i] + '</th>');
} else {
$('.optionsForm ').find('tr:eq(' + i + ')').append('<td>' + columnContent[i] + '</td>');
}
}
});
});
</script>
这是Laravel刀片中的html代码表:
<table class="optionsForm" style="width:100%">
<tbody>
<tr>
<th>
</th> @for($c = 1; $c
<=4; $c++)
<th>
<input type="text" name="columns[{{ $c }}]"
class="form-control" placeholder="Column {{ $c }} ">
</th>
@endfor
</tr>
@for($r = 1; $r
<=4; $r++)
<tr id="option{{ $r }}">
<td>
<input type="text" name="rows[{{ $r}}]" class="form-control" placeholder="Row {{ $r }} ">
<td>
<input type="radio" name="col_nr[{{ $r }}]" value="1" class="col1">
{{-- <input type="hidden" name="row_nr[{{ $r }}]" value="{{ $r }}" class="col1"> --}}
</td>
<td>
<input type="radio" name="col_nr[{{ $r }}]" value="2" class="col2">
<input type="hidden" name="row_nr[{{ $r }}]" value="{{ $r }}" class="col2">
</td>
<td>
<input type="radio" name="col_nr[{{ $r }}]" value="3" class="col3">
<input type="hidden" name="row_nr[{{ $r }}]" value="{{ $r }}" class="col3">
</td>
<td>
<input type="radio" name="col_nr[{{ $r }}]" value="4" class="col4">
<input type="hidden" name="row_nr[{{ $r }}]" value="{{ $r }}" class="col4">
</td>
<input type="hidden" value="[0]" class="row_col_nr{{ $r }}">
</tr>
@endfor
<tr>
</tr>
</tbody>
</table>
有人可以给我一点帮助,请我被困住。