Hi
I have spent 2 days struggling to get a veriable to be assigned to "City" and then added as a veriable pasted to the function getDealer.
"data" is an array filled with cities names and I index the array by using the veriable "count"
I am adding a row to a table and then adding a new cell to the row and then adding text to the cell. After this I just want to add an event to the cell so that if some one click on the cell then it is sent to the function "getDealer" and depending on the cell in which it was clicked the name of the city is passed to the function along with "Island" and "Region".
Some help on this would be magic...
data[0] = "Cambridge";
data[1] = "Hamilton";
data[2] = "TeAwamutu";
var Island = "North Island";
var Region = "Waikato";
var count = 1;
while(count < data.length-1){ // -1 because the first line in the table already displayed
var newRow = theTable.insertRow(theTable.rows.length)
newRow.id = "row"+theTable.rows.length;
var newCell
newCell = newRow.insertCell(0);
newCell.id = "cellid"+count;
newCell.innerHTML = data[count]; // City
var City = data[count];
// ADD onclick event for list (NOTE: browser dependent)
if(window.addEventListener){ // Mozilla, Netscape, Firefox
document.getElementById("cellid"+count).addEventListener('click', function() {getDealer(Island,Region,City)}, false);
} else { // IE
document.getElementById("cellid"+count).attachEvent('onclick', function(){getDealer(Island,Region,City)});
}
count++;
}
function getDealer(Island,Region,City){
alert(Island+","+Region+","+City);
}