I added an AJAX search feature to my website. It works similar to the new windows vista start menu search shortcut feature.

What happens is the user requests a keyword search, the request is sent to a PHP script which sends it back to the browser. This is all done with xmlhttp, thus AJAX.

Currently I have a script where it creates the new sets of links for each result. Therefore when PHP script returns 200 linking results, then there will be 200 <a> elements (which will link to their corresponding page). What happens which each link is that the Javascript creates a new A (link) element, sets its attributes, and appends it to the parent.

However, instead of having to create so many elements, one solution would be to change the innerHTML of the parent element. So each time the results are fetched, then the innerHTML would simply be <a href="?link1">link1</a> <a href="?link2">link2</a> and so on...

So which method should be used here? Both work, only I don't think that the innerHTML solution is correct and the createElement method is too slow...