Although i'm working on ASP.net, i think the problem i'm facing is related to my javascript function so i hope i create the thread in the right section.
My goal is to create a table dynamically, depending with the number of cameras i got. The code is:
tabela --> a string that will have stored the whole table;
lastCol --> a flag i use to know when i am about to creat a third column, so i can after create another row;
nCam --> the number of cameras i got.
So my intention is increment on the string tabela each column and row according to the number of cameras, but what happen is that in 4 cameras, the webpage just show the last one :(
i put the alert() function to see what the string ‘tabela’ has and it show:
Why dont he increment the code that the compiler already passes through on the 'if' conditions?
I'm not good at javascript so i thought the code sintax maybe could be wrong. Someone can help me? Warn me if i wasnt too clear.
Thanks in advance.
My goal is to create a table dynamically, depending with the number of cameras i got. The code is:
Code:
var tabela = "<table border=2 width='100%' heigth='100%'><tr>";
var lastCol = 3;
for (var i = 1; i <= nCam; i++)
{
if (i == lastCol)
{
if(i = nCam)
{
tabela += "</tr><tr><td><img src=\"http://server.ubiwhere.com/cgi-bin/nph-zms?mode=jpeg&monitor=" + i + "\" /></td></tr></table>";
}
else
{
tabela += "</tr><tr><td><img src=\"http://server.ubiwhere.com/cgi-bin/nph-zms?mode=jpeg&monitor=" + i + "\" /></td>";
}
lastCol = lastCol + 3;
}
else if (i = nCam)
{
tabela += "<td><img src=\"http://server.ubiwhere.com/cgi-bin/nph-zms?mode=jpeg&monitor=" + i + "\" /></td></tr></table>";
}
else
{
tabela += "<td><img src=\"http://server.ubiwhere.com/cgi-bin/nph-zms?mode=jpeg&monitor=" + i + "\" /></td>";
}
}
document.getElementById("montCam").innerHTML = tabela;
lastCol --> a flag i use to know when i am about to creat a third column, so i can after create another row;
nCam --> the number of cameras i got.
So my intention is increment on the string tabela each column and row according to the number of cameras, but what happen is that in 4 cameras, the webpage just show the last one :(
i put the alert() function to see what the string ‘tabela’ has and it show:
Code:
<table border=2 width='100%' heigth='100%'><tr><td><img src=\"http://server.ubiwhere.com/cgi-bin/nph-zms?mode=jpeg&monitor=4/></td></tr></table>
I'm not good at javascript so i thought the code sintax maybe could be wrong. Someone can help me? Warn me if i wasnt too clear.
Thanks in advance.
Comment