I'm trying to send student marks to the server which will then catch in the container and will be stored in the database.
So, in vue I'm fetching all students by for each, so I have showing list of student names and an empty input type of text in which their marks are going to be written and a submit button at the end of the form which will be sending:
student-ids, and marks.
So how can I achieve this? I tried v-model on marks but it was repeating the same marks on each input also I was not able to send student id's along with their marks.
<tr v-for="student in students">
<td>{{student.name}}</td>
<td>{{student.college_id}}</td>
<td><input type="text"></td>
</tr>
The above one is for retrieving the users and displaying in the table, how can I send their marks which will be filled to the server along with their ids so that I could know who they are.
OK, so next question, do you want to submit all data together, e.g. using a ng-submit or ng-click event listener, or do you want to submit whenever each result is entered (one listener per table row)?
@abusalameh Thanks for your reply, I trying to get what you are saying but I'm not understanding how can I then get the array of all input values and send it to server. In my case the teacher would enter the obtained marks in the input field in front of each student, once teacher finishes filling marks, he would then press submit button which will then stored. (Storing marks along with student ids, that's what I can't do)
you've just get students from database and assigned it to this.students in vue data object.
submit the data to your url using ajax
example :
this.$http.post(url, {students, this.students}).then(function(res){
console.log(res);
// you can console log the json response from the server side
},function(err){
// error is handled here
});
in serverside ( laravel )
<?php
// inside the controller method
// this will bring the array of students
dd(request()->students);
@abusalameh GREATT!!!!! you just solved one of the great problem I was facing. Can you please tell me is there any way to make marks '0' if any of the input is left empty?