I'd really appreciate if somebody could help me out with this. I've been going through similar questions asked but none seem to help with my problem.
I have a User table in a go template. In the right most column I have two buttons to update and delete a user. I want these buttons to point to a url that will update and delete that specific user. So I need to have the user id in the url.
This is the code:
<table class="table table-striped">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Date Of Birth</th>
<th>County</th>
<th>Books</th>
<th>Perform Action</th>
</tr>
</thead>
<tbody>
{{ range .Users}}
<tr>
<td>{{ .Id }}</td>
<td>{{ .Name }}</td>
<td>{{ .DateOfBirth }}</td>
<td>{{ .County }}</td>
<td>
{{if .Books}}
{{ range $id, $book := .Books }}
<li>{{ $book.Title }}</li>
{{ end }}
{{else}}
No Books
{{end}}
</td>
{{ $updateUrl := "http://localhost:8080/library/updateuser/" + .Id }}
<td>Update UserDelete User</td>
</tr>
{{ end}}
</tbody>
</table>
In the 5th line up from the bottom you'll see my incorrect attempt at concatenating the href with the id.
You cannot concatenate strings using +. This should work:
<a href="http://localhost:8080/library/deleteuser/{{ .Id }}">
Related
<div class="table-responsive">
<table class="table align-middle table-nowrap table-check table-striped " id="sortMe">
<thead class="table-light">
<tr>
<th city</th>
<th contry</th>
<th>address</th>
</tr>
</thead>
<tbody>
{% for offer in pagination -%}
<tr>
<td>{{ offer.city }}</td>
<td>{{ offer.contry }}</td>
<td>{{ offer.address }} %</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
All i want is to show debit and credit according to dates. I want debit to show only if there's new record added and also credit to show only if there's changes in the accounts. I have used observer to check if column is dirty.
here is my blade
<table class="table table-striped">
<thead style="background-color: #0b8a83;color:rgb(0, 0, 0);">
<th>Date</th>
<th>Description</th>
<th>Credit</th>
<th>Debit</th>
<th>Balance</th>
</thead>
#foreach ($monthlyInst as $keyy)
<tr>
<td>{{ date('d/M/y', strtotime($keyy->updated_at)) }}</td>
<td></td>
<td></td>
<td>R {{ $keyy->Installment }}</td>
<td></td>
</tr>
#endforeach
#foreach ($history as $account)
<tr>
<td>{{ date('d/M/y', strtotime($account->updated_at)) }}</td>
<td>{{ $account->accountname }}</td>
<td>R {{ $account->newpaid }}</td>
<td></td>
<td>R {{ $account->newbal }}</td>
</tr>
#endforeach
<tr>
<td></td>
<td>Outstanding Balance</td>
<td></td>
<td></td>
<td><b>R {{ $totalbal }}</b></td>
</tr>
</table>
Below shows my data. I am trying to loop Item inside table <td> tag so that it forms two items in one column.
user
>"name":"Bob"
>"id":1
>"Item":
>"name":"Desk"
>"name":"Chair"
Code
<table class="table table-hover">
<tbody>
<tr>
<th>Name</th>
<th>Items</th>
</tr>
<tr v-for="use in user.data" :key="use.id">
<td>{{ use.name }}</td>
<td v-for="a in use.item">
{{ a.name }},
</td>
</tr>
</tbody>
</table>
But when I do the codes above, it produce another column just like below picture. How do I put the Desk and Chair sits together in one column?
Hi just use a span tag in side td here is my solution, p or div tag are block tags, if you are using bootstrap 4 just set class to span inline-block or inline
<table class="table table-hover">
<tbody>
<tr>
<th>Name</th>
<th>Items</th>
</tr>
<tr v-for="use in user.data" :key="use.id">
<td>{{ use.name }}</td>
<td>
<span v-for="a in use.item"> {{ a.name }}, </span>
</td>
</tr>
</tbody>
</table>
v-for crates another elemenrs for you in each iteration. Use join function to display together
<tr v-for="use in user.data" :key="use.id">
<td>{{ use.name }}</td>
<td>
{{ use.item.join(", ") }},
</td>
</tr>
Output would be Desk, Chair
We can do this with using lodash
`
<tr v-for="use in user.data" :key="use.id">
<td>{{ use.name }}</td>
<td>
{{ _.map(use.item, 'name').join(", ") }}
</td>
</tr>
`
i am trying to display the laravel mmysql data in text field values, i am displaying upto table format, but i also need to update that value of the filed, like text filed values,
here is my code to display data in table format
<table border=1 align=center>
<thead>
<tr>
<td><h4>Name</h4></td>
<td><h4>Phoneno</h4></td>
<td><h4>Checkpost</h4></td>
<td><h4>Usertype</h4></td>
</tr>
</thead>
<tbody>
#foreach($profile as $user)
<tr>
<td>{{ $user->name }}</td>
<td>{{ $user->phoneno }}</td>
<td>{{ $user->checkpost }}</td>
<td>{{ $user->usertype }}</td>
</tr>
#endforeach
</tbody>
</table>
#endsection
I want to create a radio button field that will be selecting present, late, absent, others for each row of student.
The problem is... When i click the radio button for another student row... the radio button will pass down on the currently selected row and the one i selected previously will be gone.
Please Help.
Here's my view
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Student ID</th>
<th>Student Name</th>
<th>Present</th>
<th>Late</th>
<th>Absent</th>
<th>Others</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
#foreach ($users as $users)
<tr>
<td>{{ $users->student_id }} </td>
<td>{{ $users->student_firstname }} {{ $users->student_lastname }}</td>
<td>{{ Form::radio('result', 'present', true)}}</td>
<td> {{ Form::radio('result', 'late' ) }}</td>
<td>{{ Form::radio('result', 'absent') }}</td>
<td>{{ Form::radio('result', 'others') }}</td>
<td> <input id="comment" name="comment" type="text" class="form-control"></td>
#endforeach
</tr>
If all input fields have the exact same name of results its treated as one big input group with only one correct answer.
By appending the student id 'result['.$student->id.']' you are separating each row of input buttons into their own groups, allowing multiple radio button subgroups within a single <form>.
Which you can then catch the array of answers for each subgroup with Input::get('results') or $request->get('results') if your using Laravel's Form Request Validation.