so for my code i have i'm trying to pass along the i variable in the for loop but when i pass it on it passes the highest i value. so when it should be one it passes along 10. i am curretnly passing along the cell6 id and splitting it up to get the i value. not really sure what to do with it. thanks for the help in advance.
function displaySearch(){
var div = document.getElementById('table')
var table = document.getElementById('tableSearch')
var res = xmlhttp.responseXML
var e = res.getElementsByTagName('element')
for(var i = 0; i < e.length; i++){
var splitResult = e[i].textContent.split('#')
var course = splitResult[0]
var num = splitResult[1]
var tut = splitResult[2]
var email = splitResult[3]
var capacity = splitResult[4]
var rowCount = table.rows.length
var row = table.insertRow(rowCount)
var cell1 = row.insertCell(-1)
cell1.id = "1" + i
cell1.innerHTML = course
var cell2 = row.insertCell(-1)
cell2.id = "2" + i
cell2.innerHTML = num
var cell3 = row.insertCell(-1)
cell3.id = "3" + i
cell3.innerHTML = tut
var cell4 = row.insertCell(-1)
cell4.id = "4" + i
cell4.innerHTML = email
var cell5 = row.insertCell(-1)
cell5.id = "5" + i
cell5.innerHTML = capacity
var cell6 = row.insertCell(-1)
cell6.id = "6" + i
var reg = document.createElement('input')
reg.type = 'button'
reg.value = "Register"
reg.id = i
reg.name = i
reg.onclick = function(){registerCourse(cell6.id)}
var cell = "row"+i
cell6.appendChild(reg)
}
}