I found some fantastic code that meets the needs for my project from here:
http://www.askthecssguy.com/examples/rowlock/example9.html
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)
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.
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.
This is the original code from the link above:
function lockRow() {
var tables = document.getElementsByTagName("table");
for (var m=0; m<tables.length; m++) {
if (tables[m].className == "pickme") {
var tbodies = tables[m].getElementsByTagName("tbody");
for (var j=0; j<tbodies.length; j++) {
var rows = tbodies[j].getElementsByTagName("tr");
for (var i=0; i<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);
}
}
}
}
}
Which I hacked down to:
function testloop()
{
var tables = document.getElementsByTagName("table");
for (var m=0; m<tables.length; m++) {
var tbodies = tables[m].getElementsByTagName("tbody");
for (var j=0; j<tbodies.length; j++) {
var rows = tbodies[j].getElementsByTagName("td");
for (var i=0; i<rows.length; i++) {
r = rows[ i ] ;
// r is the radio button.
//How do I access the text in the 2nd column?
}
}
}
}
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.
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.
<tr>
<td>
<input
type="radio"
name="choice"
value="walalala" />
</td>
<td>Domestic</td>
<td>Titanic</td>
<td>$600,788,188</td>