0

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user1925079
  • 23
  • 1
  • 4
  • 3
    You can’t do such things in HTML. HTML is a markup language, not a programming language. You should explain what software you are using to generate the HTML document and reformulate the question. – Jukka K. Korpela Dec 23 '12 at 15:35
  • In what context do you want to do this? Is the page dynamically generated? Do you what to add the code as the page is generated? Are you trying to do this on an already rendered page? Maybe with Javascript? – s_ha_dum Dec 23 '12 at 15:36

1 Answers1

0

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.

Community
  • 1
  • 1
Kuf
  • 17,318
  • 6
  • 67
  • 91
  • ok i will test the query method but is it also possible to add predefined code and later change it? thx for the tip – user1925079 Dec 23 '12 at 16:02
  • Thx alot for the tip it works i only need to save the html code afterwards. – user1925079 Dec 23 '12 at 22:44
  • I am sorry i an late yeah Thx alot for the jquery advice i am working myself in it although i am not a Programmer but i found some usefull codes on DataTables site. Also after generating the site you can mark the whole site with Ctrl+a and then right click and choose source code it will show the generated code whill be visible. Thx alot for the help. – user1925079 Dec 24 '12 at 13:30