My goal is to create a table dynamically, depending with the number of cameras i got. The code is:
Expand|Select|Wrap|Line Numbers
- 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:
Expand|Select|Wrap|Line Numbers
- <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.