HAL: Search String

Beitrag lesen

The 2nd problem is the followin: I wanna get a new div for every one of those outputs, but i don't get. I use a for (var bla bla bla)

  	var kol = document.getElementById("kol");  
  	var newdiv = document.createElement('div');  
  	newdiv.id = 'hallo';  
  	newdiv.innerHTML = '<div id="klasse1">Search: ' + search\_output[i]["name"];  
  	kol.appendChild(newdiv);  

And i defined a css id with "klasse1" and told it that there should be top 5px, but all those divs just still hang together.

Hello!

About the 2nd problem - try this:

  
var kol = document.getElementById("kol");  
var newdiv = document.createElement('div');  
newdiv.setAttribute("id","hallo");  
kol.appendChild(newdiv);  
newdiv.innerHTML = '<div id="klasse1">Search: ' + search_output[i]["name"];  

First you have to append the DIV into the DOM before you can use innerHTML. Same thing with newdiv.id. This argument only works on existing elements (AFAIK), try setAttribute() to set the id.

Greetings