Here is an example that may solve your requirements:
1) As I mentioned in a comment, There is an html table with three columns.
2) Sorts cars by model name.
3) When the models are clicked, additional information is displayed about the car. (in this case, in an alert window)
4) You can add cars to the list with the form, and the table is then regenerated.
Run code here.
<html>
<head>
<title>Just for fun</title>
</head>
<body>
<h3>Cars and types:</h3>
<form name="myForm" onsubmit="return mysubmit()">
Model: <input type="text" name="model"><br>
Count: <input type="text" name="count"><br>
Details: <input type="text" name="details"><br>
<input type="submit" value="Submit">
</form>
<button onclick="generate_table()">Generate Table</button><br>
<table class="cars">
</table>
<div class="details" style="float:right;">
</div>
<script>
console.log('script started');
var cars = [
{model: "BMW", count: 23, details: "<p>I like <b>X6</b> from Germany</p>"},
{model: "Hyundai", count: 30, details: "<p>I have <b>Verna</b> from Korea</p>"},
{model: "Toyota", count: 08, details: "<p>Small <b>Yaris</b> from Japan</p>"},
{model: "Fiat", count: 12, details: "<p>Latest <b>500c</b> from Italy</p>"}
]
var types = ["model","count","details"];
function generate_table() {
cars.sort(compare);
var body = document.getElementsByTagName("body")[0];
// creates a <table> element and a <tbody> element
var tbl = document.getElementsByClassName("cars")[0];
tbl.innerHTML = '';
var tblBody = document.createElement("tbody");
console.log(cars.length);
for (var i = 0; i < 3; i++) {
var index = ((j*3)+i);
if (index < cars.length) {
// Create a <td> element and a text node, make the text
// node the contents of the <td>, and put the <td> at
// the end of the table row
var cell = document.createElement("td");
var num = index;
cell.innerHTML = '<a href="#" onclick="showDetailsAsDiv('+num.toString()+')">' + cars[index][types[0]] + '</a> (' + cars[index][types[1]] + ')';
row.appendChild(cell);
}
}
tbl.appendChild(tblBody);
body.appendChild(tbl);
tbl.setAttribute("border", "2");
}
// This function throws details into 'details' div
function showDetails(num) {
console.log('details showing',num);
div = document.getElementsByClassName('details')[0];
div.innerHTML = '';
var car = cars[num];
div.innerHTML = 'Model: ' + car.model + '</br>Count: ' + car.count +
'</br>Details:\t' + car.details;
}
function mysubmit() {
var model = document.forms["myForm"]["model"].value
var count = document.forms["myForm"]["count"].value
var details = document.forms["myForm"]["details"].value
cars.push({
model:model,
count:count,
details:details
});
generate_table();
return false;
}
function compare(a,b) {
if (a.model < b.model)
return -1;
if (a.model > b.model)
return 1;
return 0;
}
</script>
</body>
</html>
EDIT: Changed code to throw details into div instead of alert box - this way you can see the HTML being run.
EDIT2: Shows cars in 3 columns.
References:
Sorting Function
generate_table function [slightly modified]