luckydexte
Programmer
Hello all,
I am trying to create a popup div tag on the fly (which is working) but I need to create a list of links and call a javascript function with a parameter. The values I am trying to send in are being sent in as strings and not the variables. Has anyone come across this before? A snippet of my code is below.
string = "<span id=\"close\"><a href=\"javascript:setVisible('miscLayer')\" style=\"text-decoration: none\"><strong>Hide</strong></a></span>";
string += "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">";
for (i=0;i<x.length;i++) {
segIdArray = x.childNodes[1].childNodes[0].nodeValue;
string += "<tr>";
string += "<td class=\"text\"><a href=\"javascript:LoadRoadCond(i);\">" + x.childNodes[1].childNodes[0].nodeValue + "</a></td>";
string += "<td class=\"text\">" + x.childNodes[6].childNodes[0].nodeValue + "</td>";
string += "<td class=\"text\">" + x.childNodes[7].childNodes[0].nodeValue + "</td>";
string += "<td class=\"text\">" + x.childNodes[8].childNodes[0].nodeValue + "</td>";
string += "<td class=\"text\">" + x.childNodes[0].childNodes[0].nodeValue + "</td>";
string += "</tr>";
}
string += "</table>";
miscLayer.innerHTML = string;
alert(miscLayer.innerHTML);
setVisible('miscLayer');
The string that is created is below:
<span id="close"><a href="javascript:setVisible('miscLayer')" style="text-decoration: none"><strong>Hide</strong></a></span>
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<td class="text"><a href="javascript:LoadRoadCond(i);">56683</a></td>
<td class="text">6444</td>
<td class="text">West St</td>
<td class="text">split north of Forest Dr</td>
<td class="text">81</td>
</tr>
<tr>
<td class="text"><a href="javascript:LoadRoadCond(i);">56686</a></td>
<td class="text">6444</td>
<td class="text">Admiral Cochrane Dr</td>
<td class="text">Split north of Forest Dr</td>
<td class="text">60</td>
</tr>
</table>
That is all correct. However, the function LoadRoadCond gets the variable i and it uses 2 every time. 2 is what i is after the loop ends.
Any ideas?
Thanks,
Brandon
I am trying to create a popup div tag on the fly (which is working) but I need to create a list of links and call a javascript function with a parameter. The values I am trying to send in are being sent in as strings and not the variables. Has anyone come across this before? A snippet of my code is below.
string = "<span id=\"close\"><a href=\"javascript:setVisible('miscLayer')\" style=\"text-decoration: none\"><strong>Hide</strong></a></span>";
string += "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">";
for (i=0;i<x.length;i++) {
segIdArray = x.childNodes[1].childNodes[0].nodeValue;
string += "<tr>";
string += "<td class=\"text\"><a href=\"javascript:LoadRoadCond(i);\">" + x.childNodes[1].childNodes[0].nodeValue + "</a></td>";
string += "<td class=\"text\">" + x.childNodes[6].childNodes[0].nodeValue + "</td>";
string += "<td class=\"text\">" + x.childNodes[7].childNodes[0].nodeValue + "</td>";
string += "<td class=\"text\">" + x.childNodes[8].childNodes[0].nodeValue + "</td>";
string += "<td class=\"text\">" + x.childNodes[0].childNodes[0].nodeValue + "</td>";
string += "</tr>";
}
string += "</table>";
miscLayer.innerHTML = string;
alert(miscLayer.innerHTML);
setVisible('miscLayer');
The string that is created is below:
<span id="close"><a href="javascript:setVisible('miscLayer')" style="text-decoration: none"><strong>Hide</strong></a></span>
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<td class="text"><a href="javascript:LoadRoadCond(i);">56683</a></td>
<td class="text">6444</td>
<td class="text">West St</td>
<td class="text">split north of Forest Dr</td>
<td class="text">81</td>
</tr>
<tr>
<td class="text"><a href="javascript:LoadRoadCond(i);">56686</a></td>
<td class="text">6444</td>
<td class="text">Admiral Cochrane Dr</td>
<td class="text">Split north of Forest Dr</td>
<td class="text">60</td>
</tr>
</table>
That is all correct. However, the function LoadRoadCond gets the variable i and it uses 2 every time. 2 is what i is after the loop ends.
Any ideas?
Thanks,
Brandon