Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I change the table elements in this Javascript code?
    primarykey
    data
    text
    <p>I found some fantastic code that meets the needs for my project from here:</p> <p><a href="http://www.askthecssguy.com/examples/rowlock/example9.html" rel="nofollow">http://www.askthecssguy.com/examples/rowlock/example9.html</a></p> <p>I've modified the code so that when the user selects an item and then clicks a button the data is processed (e.g. erase the data from a database on the server)</p> <p>I have not been able to figure out is how to disable the action from occurring again. I've tried disabling the radio button. The code somehow reactivates the radio button. I've set the radio button to null. That too didn't work.</p> <p>My last thought was to change the text in the 2nd column (the first is the radio button) as a means of testing if the code has already been deleted but I simply can't figure out how to access that column and modify the text. </p> <p>This is the original code from the link above:</p> <pre><code>function lockRow() { var tables = document.getElementsByTagName("table"); for (var m=0; m&lt;tables.length; m++) { if (tables[m].className == "pickme") { var tbodies = tables[m].getElementsByTagName("tbody"); for (var j=0; j&lt;tbodies.length; j++) { var rows = tbodies[j].getElementsByTagName("tr"); for (var i=0; i&lt;rows.length; i++) { rows[i].oldClassName = rows[i].className; rows[i].onclick = function() { if (this.className.indexOf("selected") != -1) { this.className = this.oldClassName; } else { removeSelectedStateFromOtherRows(); addClass(this,"selected"); } selectRowRadio(this); } } } } } </code></pre> <p>Which I hacked down to:</p> <pre><code>function testloop() { var tables = document.getElementsByTagName("table"); for (var m=0; m&lt;tables.length; m++) { var tbodies = tables[m].getElementsByTagName("tbody"); for (var j=0; j&lt;tbodies.length; j++) { var rows = tbodies[j].getElementsByTagName("td"); for (var i=0; i&lt;rows.length; i++) { r = rows[ i ] ; // r is the radio button. //How do I access the text in the 2nd column? } } } </code></pre> <p>}</p> <p>If the row with 'Domestic' was selected, I'd like to change 'Domestic' to 'Deleted'. I can detect that in other code and handle that action.</p> <p>Does this make any sense? Is there a smarter or easier way of what I'm trying to accomplish? My Javascript abilities are sorely lacking. Thank you.</p> <pre><code>&lt;tr&gt; &lt;td&gt; &lt;input type="radio" name="choice" value="walalala" /&gt; &lt;/td&gt; &lt;td&gt;Domestic&lt;/td&gt; &lt;td&gt;Titanic&lt;/td&gt; &lt;td&gt;$600,788,188&lt;/td&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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