ab5ni
Posts: 177
|
| Posted: 03/14/2007, 1:06 PM |
|
Howdy Folks,
Most of the day today, we've been trying to find out which row was being chosen when
an editable grid's check-box has been selected. The exact row can be found by
adding "this" as a parameter to a function called during the JavaScript
onclick() event .
// In this context, "this" refers to this particular CheckBox on "this" particular row.
<td><input onclick="OpenPopupList(this)" type="checkbox" value="1" name="{hm_Name}" {hm}></td>
function OpenPopUpList(chkbox)
{
if (chkbox.checked){
if(document.getElementsByTagName){
var table = document.getElementById("recv_table"); // ID added by us to find this particular table.
var myrows = table.getElementsByTagName("tr");
for(i = 0; i < myrows.length ; i++){
text = "hm_"+i; // Every row has a concatenated underscore and consecutive # _1,_2,_3, etc.
if(chkbox.name == text){
var the_itemid = GetInputValue("itemid_"+i); // Now have the proper row.
break;
}
}
if(the_itemid){
var win=window.open("hazmat.php?itemid="+the_itemid,"popupname","top=200,left=200,width=1000,height=500,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
win.focus();
}
}
}
}
function GetInputValue(item)
{
var the_value;
if(document.getElementsByTagName){
var table = document.getElementById("recv_table");
var myrows = table.getElementsByTagName("input");
for(var i = 0; i < myrows.length; i++) {
var the_name = myrows.getAttribute("name");
if(the_name == item) {
var the_value = myrows.getAttribute("value");
break;
}
}
return the_value;
}
else {
return false;
}
}
Guess the code could be optimized a bit, but at this stage, I'm just a neophyte trying
to get some code going to make a deadline . In other words, I'll clean it up later,
and it works . Yeah. Right. Sure! 
Anywho, I've never seen this particular question answered here, although I've seen
it asked a few times searching the historical messages here. Also, I hope this
saves some of you guys some time, because God only knows it ate up a bunch
of mine! 
Regards,
Randall
_________________
Randall Jouett
Amateur Radio: AB5NI
I eat spaghetti code out of a bit-bucket while sitting at a hash table! And yes, I paid for the meal in cache!
|