Note that there are some explanatory texts on larger screens.

plurals
  1. POnextSibling issues
    text
    copied!<p>Ok, this has been killing me all night, I mean I've been working on this code for atleast 8 hours now. What is the problem with this, argggg.</p> <p>I am trying to update all <code>&lt;span id="column_[row index number]_[column index number]_[layout position number]"&gt;</code> to increment it by one up until the next <code>id="row_[row index number]"</code> <code>tr element</code>, The tr elements that it should be searching in has an id of <code>tr_[row index number]_[column index number]_[layout position number]</code> but for some god knows what reason, it gives me issues. It's updating the same <code>&lt;span&gt;</code> tag 2x, and this changes it from the desired value to 1 more than it should be... There's only <code>1 &lt;span&gt;</code> tag within the <code>firstChild &lt;td&gt; element</code> of each of the <code>&lt;tr&gt; elements</code>. I just don't understand why it is setting it 2x for just 1 of them, and it seems that it's random or something. argggg.</p> <p>There's only 1 <code>&lt;span&gt;</code> element in the <code>&lt;td id="tdcolumn_[row index number]_[column index number]_[layout position number]&gt;</code> tag, but for some reason, it is calling the same tag twice. It should only call it once. arggg. I don't understand why??</p> <p>Here's my code someone please help me here...</p> <pre><code>// Reorder all columns, if any, in the other rows after this 1. if (aRowId != 0 &amp;&amp; lId.indexOf("tr_" + aRowId) == 0 &amp;&amp; rowComplete != aRowId) { var tempTr = lTable.childNodes[i].childNodes[p]; while(tempTr.nodeType == 1 &amp;&amp; tempTr.nextSibling != null) { var tempId = tempTr.getAttribute("id"); if (!tempId) continue; if (tempId.indexOf("row_") == 0) { // All done this row, set it to completed! rowComplete = aRowId; break; } if (tempTr.hasChildNodes) { var doneChilds = false; // grab the id where tdcolumn_{aRowId}.indexOf = 0. for (fcTd = 0; fcTd&lt;tempTr.childNodes.length; fcTd++) { if (tempTr.childNodes[fcTd].nodeName == '#text') continue; var tempfcId = tempTr.childNodes[fcTd].getAttribute("id"); if (!tempfcId) continue; if (tempfcId.indexOf("tdcolumn_" + aRowId) != 0) continue; // looping through the children in the &lt;td&gt; element here. if (tempTr.childNodes[fcTd].hasChildNodes) { for (x = tempTr.childNodes[fcTd].childNodes.length-1; x&gt;0; x--) { if (tempTr.childNodes[fcTd].childNodes[x].nodeName == '#text') continue; var tempSpanId = tempTr.childNodes[fcTd].childNodes[x].getAttribute("id"); if (!tempSpanId) continue; if (tempSpanId.indexOf("column_") != 0) continue; // alert(tempSpanId); alert(tempTr.childNodes[fcTd].childNodes[x].nodeName); var tSpanId = new Array(); tSpanId = tempSpanId.split("_"); if (currColumnId == 0) { currColumnId = parseInt(tSpanId[1]); var incCol = currColumnId; } incCol++; // alert("currColumnId = " + currColumnId + "\n\ntSpanId[1] = " + tSpanId[1] + "\n\nincCol = " + incCol); // Set the new Id's and Text, after which we can exit the for loop. tempTr.childNodes[fcTd].childNodes[x].setAttribute("id", "column_" + incCol); tempTr.childNodes[fcTd].childNodes[x].setAttribute("class", "dp_edit_column"); tempTr.childNodes[fcTd].childNodes[x].innerHTML = oColumnText + " " + incCol; // tempTr.childNodes[fcTd].setAttribute("id", "tdcolumn_" + aRowId + "_" + (parseInt(tSpanId[1])+1) + "_" + tSpanId[3]); doneChilds = true; break; } } else continue; if (doneChilds == true) continue; } } else continue; tempTr = tempTr.nextSibling; } } </code></pre> <p>Please help me, Thank You :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload