0
我是laravel 4的新手,所以請容忍我。我想將我從create.blade.php
文件獲得的數據存儲到控制器的store()
方法中。但是我在控制器部分變得無能爲力。使用laravel插入多行到數據庫表4
這裏是我的create.blade.php
文件
<p>
<strong>Select No of Activites You Want To Fill Up:</strong> {{ Form:: select('noAct',array('1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5),'1',array('id'=>'noAct')); }}</strong>
</p>
<table class="table table-bordered">
<tr>
<th>SN</th>
<th>Activity Description</th>
<th>Unit</th>
<th>Weightage</th>
<th>Date</th>
<th>100</th>
<th>75</th>
<th>50</th>
<th><50</th>
</tr>
<!--form to insert the user data-->
{{ Form::open(array('url'=>'it')) }}
<tbody id="tbodyappend"></tbody>
<tbody>
<tr>
<td colspan="9" style="text-align:center;">{{ Form::submit('Add Activity',array('class'=>'btn btn-primary')) }}</td>
</tr>
</tbody>
{{ Form::close() }}
</table>
<script>
$(document).ready(function() {
function displayTable() {
var noAct = $("#noAct").val();
$("#tbodyappend").empty();
//for loop to display the no of tables required
for (var i = 0; i < noAct; i++) {
//display the table
$("#tbodyappend").append("<tr><td>" + (i + 1) + "</td><td><input type='text' name='activity_name[]' required /></td><td><input type='text' name='activity_unit[]' required style='width:40px;' /></td><td><input type='text' name='activity_weight[]' required style='width:40px;' /></td><td><input type='text' name='activity_date[]' required style='width:40px;' /></td><td><input type='text' name='performance1[]' required style='width:40px;' /></td><td><input type='text' name='performance2[]' style='width:40px;' /></td> <td><input type='text' name='performance3[]' style='width:40px;' /></td><td><input type='text' name='performance4[]' style='width:40px;' /></td></tr>");
}
}
$("select").change(displayTable);
});
</script>
所以,現在我想將數據發送到我的控制器並插入到表中。所以,任何幫助對我都有很大的幫助。
你可以看到的是什麼,我想在這裏做的類似的表:http://jsfiddle.net/xn2GP/1/
而且你可以看到我貼:http://laravel.io/bin/RWXK
我們不能追加使用jQuery一個輸入字段? – Crestamr
你可以在這裏看到類似的部分:http://jsfiddle.net/xn2GP/1/你可以檢查我的粘貼在http://laravel.io/bin/RWXK – Crestamr
檢查出 – johnRivs