Image:
[
^]
What i need is that when i click on a cell, for example cell [2,2] which contains "PMS03", i want to have an alert which displays ALL cells that contain PMS03, this would be alert("Positions: [2,1], [2,2], [3,7]");
I figured that somehow i would make a 2nd array during the process of creating the "pointmapS" (=puntmapS) but i think the best idea would be to get some experts like you guys to help me with this as there should be quite a few solutions (and more efficient) to this that i am probably not aware of.
Creating the mapping array:
var jPunten = JSON.parse(data);
var puntmapS = [];
var cardsS = [];
var prevCard = jPunten[0].KARTNR;
cardsS[0] = jPunten[0].KARTNR;
for (var i=0;i<jPunten.length;i++)
{
if(prevCard!=jPunten[i].KARTNR){
cardsS[sCounter+1]=jPunten[i].KARTNR;sCounter++;
}
puntmapS[sCounter] = puntmapS[sCounter] || [];
console.log("S|| prevCard: "+ prevCard + " === " + jPunten[i].KARTNR +" (Kartnr)");
puntmapS[sCounter][jPunten[i].BITNRK-1] = jPunten[i].STATDEV;
console.log("S|| "+" --SCounter: "+ sCounter + " bit: " + jPunten[i].BITNRK + " = " + jPunten[i].STATDEV);
}
Creating the table:
if(puntmapS.length!=0){
table = "<table style='margin-removed20px;font-size:80%;' border='1'><tbody><tr><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr><tr><th>"+cardsS[0]+ " S</th>";
for (var i=0;i<sCounter+1;i++)
{
for (var x=0;x<16;x++)
{
if(puntmapS[i][x]!=undefined)
{
table+= "<td><a href='#' önClick='alert(\""+puntmapS[i][x]+"\")'>"+puntmapS[i][x]+"</a></td>";
}
else
{
table += "<td style='background-color:#E6E6E6'><a href='#' önClick='alert(\"EMPTY\")'> </a></td>";
}
}
if(i<(sCounter)){
table+="</tr><tr><th>"+(cardsS[i+1])+" S</th>";
}
}
table += "</tr></table>";
}
jPunten looks like this:
0
Object { 0="LSZ09 ", 1="1", 2="S", more...}
0
"LSZ09 "
1
"1"
2
"S"
3
"0"
4
"1"
5
"0"
6
"I "
BITNRK
"1"
BITSTATUS
"0"
DEVPKT
"1"
KARTNR
"0"
PKTTYP
"S"
STATDEV
"LSZ09 "
TYPE
"I "