Just a guess as to what you are trying to do ...
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title> Untitled </title>
</head>
<body>
<div id="risultatiRicerca"></div>
<script type="text/javascript">
// simulation of 'xmlhttp.responseText;' //response from an ASP script called with AJAX
var strMsg = ['Now','is','the','time','for','all','good','men','to','come'];
for (var i=0; i<strMsg.length; i++) {
var elm=document.createElement('div');
elm.innerHTML = strMsg[i]; // xmlhttp.responseText; //response from an ASP script called with AJAX
elm.setAttribute('onclick', 'prova(this.innerHTML)');
document.getElementById("risultatiRicerca").appendChild(elm)
}
function prova(str) { alert("Text into element: " + str); }
</script>
</body>
</html>
Bookmarks