I am currently using a table and would like to know now if it is possible to add columns with predefined code in the first and last cell.
Here is my current table code:
<div>
<table id="myTable" class="tablesorter">
<colgroup>
<col class="nam">
<col class="dastgah">
<col class="inform">
<col class="sherkat">
<col class="reviews">
<col class="genre">
<col class="dastgahedigar">
<col class="saal">
<col class="didam">
<col class="seriesid">
</colgroup>
<thead>
<tr>
<th>Nam</th>
<th>Dastgah</th>
<th>Info</th>
<th>Sherkat</th>
<th>R</th>
<th>Type</th>
<th>Dastgahe Digar</th>
<th>Saal</th>
<th>Baazi<br>Kardam<br>Didam</th>
<th>Series<br>ID</th>
</tr>
</thead>
<tbody>
<tr class="">
<td><a>23 Matches</a></td>
<td><a>Bally Astrocade TAPE</a></td>
<td><a>Tape from the Bob Fabris Collection</a></td>
<td><a>Rich Tietjens</a></td>
<td><a></a></td>
<td><a></a></td>
<td><a></a></td>
<td><a>1980</a></td>
<td><a></a></td>
<td><a></a></td>
</tr>
I want to add a column at the beginning and a column at the end of the table like this:
<tr class="">
<td><img src="test.png" width="130" height="180" align="middle" ></td>
<td><a>23 Matches</a></td>
<td><a>Bally Astrocade TAPE</a></td>
<td><a>Tape from the Bob Fabris Collection</a></td>
<td><a>Rich Tietjens</a></td>
<td><a></a></td>
<td><a></a></td>
<td><a></a></td>
<td><a>1980</a></td>
<td><a></a></td>
<td><a></a></td>
<td><video src="test.mp4" height="181" width="199" controls></video></td>
</tr>
I want to add the first and the last column with predefined code or at least copy the code of first and the last cell to every row.
Currently i am doing it manually with notepad. I want to add the rows and then later work on them for example the the img source will be changed later on. I think the only JavaScript is a jQuery script for listing a column ascending and descending.
I partly found the solution with the jQuery code:
$(document).ready(function(){
$('table').find('tr').each(function(){
$(this).find('td').eq(0).before('<td><img src="Dastgahaye_Nasle_3-Dateien/Aksha/C64/Cover/Cover_Nadare.png" width="130" height="180" align="middle"></td>');
});
});
Is there any way to save the code after the column was made so that it doesn`t need to generate the column every time I load the page? I tried saving it in Firefox but by doing so the column will be generated but the folder path will be deleted.
There are many ways to do, but you have to use a programming or scripting language to do so.
You can achieve that easily using jQuery, have a look at this answer: Add table row in jQuery, or using PHP (directly or using framework like codeigniter)
EDIT
To build the page dynamically (change whatever you want) just change the script or the source you’re taking it from (mysql, ajax call and so).
Try and pick a jQuery plugin which will make your life easier, you can see a list of a couple of nice plugins here.