I have a dynamically generated table that looks like this
<table width="100%">
<tr>
<th>Client ID</th>
<th>Shortname</th>
<th>Client Name</th>
<th>Client Name 2</th>
</tr>
@foreach($clients as $client)
<tr>
<td>{{$client->customer_id}}</td>
<td>{{$client->shortname}}</td>
<td>{{$client->customer}}</td>
<td>{{$client->customer_row2}}</td>
</tr>
@endforeach
I would like to be able to click on a row, and automatically populate a form with the information in the table row.
I have thought of a solution that i think should work, but I haven't really got the JS skills to write the code. This is what im thinking:
{{$row=1}}
<table width="100%">
<tr>
<th>Client ID</th>
<th>Shortname</th>
<th>Client Name</th>
<th>Client Name 2</th>
</tr>
@foreach($clients as $client)
<tr id="row{{$num}}">
<td class="clientId">{{$client->customer_id}}</td>
<td class="shortname">{{$client->shortname}}</td>
<td class="client">{{$client->customer}}</td>
<td class="clientRow2">{{$client->customer_row2}}</td>
</tr>
{{$row++}}
@endforeach
And here's some psuedo code to help you understand what im thinking:
onclick getElementById(.this)
input element with id clientId .put(this.#clientId)
input element with id shortname .put(this.#shortname)
input element with id client .put(this.#client)
input element with id clientRow2 .put(this.#clientRow2)
I hope that everybody understands what i'm trying to accomplish, and that someone is willing to help
Regards Johan