onerrorgoto
09-09-2003, 04:30 AM
Hello
I have some problem with a function(below with part of my table for clarity).
The function is supposed to get the value that is stored in a hidden inputbox that lies in a hidden td-tag.
but it seems that I cant get hold of the hidden td-element.
the error states the my var itd is not an object??
lvwGrade_hdnSelectedRowID - is set with the value of the last clicked row
tbllvwGrade_r0 - rowID with name of the table + a incrementing number
hdnKey - I have one for each row that contains different value, therefor I put it in a hidden td-tag
what have I done wrong in the function?
function lvwGrade_getKey()
{
var sId='lvwGrade_hdnSelectedRowID';
alert('sid:'+sId); //shows "lvwGrade_hdnSelectedRowID"
var hdn = document.getElementById(sId);
alert('hdn.value:'+hdn.value); //shows "tbllvwGrade_r0"
var hdnName=hdn.value + "_Key";
alert('hdnname:'+hdnName); //shows "tbllvwGrade_r0_Key"
var itd = document.getElementById(hdnName); //should get the element of "tbllvwGrade_r0_key"
alert('itd.id:'+itd.id); //error td is not an object
var key=td.childNodes[0].value;
return key;
}
<tr ID='tbllvwGrade_r0' ondblclick='javascript:lvwGrade_saveRowID(this);javascript:opengrade(this,17420)'>
<td width='5' class='listbody'></td>
<td ID=tbllvwGrade_r0_c0 class='listbody'></td>
<td ID=tbllvwGrade_r0_c1 class='listbody'>N08020</td>
<td ID=tbllvwGrade_r0_c2 class='listbody'></td>
<td ID=tbllvwGrade_r0_c3 class='listbody'></td>
<td ID=tbllvwGrade_r0_c4 class='listbody'><0.07</td>
<td ID=tbllvwGrade_r0_c5 class='listbody'></td>
<td ID=tbllvwGrade_r0_c6 class='listbody'>19.0-21.0</td>
<td ID=tbllvwGrade_r0_c7 class='listbody'>32.0-38.0</td>
<td ID=tbllvwGrade_r0_c8 class='listbody'>2.00-3.00</td>
<td ID=tbllvwGrade_r0_c9 class='listbody'>Cu:3.0-4.0 Mn:<2.00 Nb:8xC-1.00 P :<0.045 S :<0.035 Si:<1.00 </td>
<td ID=tbllvwGrade_r0_ID' style='display:none'><input ID='hdnID' type='hidden' value=''></td>
<td ID=tbllvwGrade_r0_Key' style='display:none'><input ID='hdnKey' type='hidden' value='79356key'></td>
</tr>
</TBODY>
<TFOOTER>
<tr ID="tblfooter">
<td>
<input id='lvwGrade_hdnSelectedRowID' type='hidden' name='lvwGrade_hdnSelectedRowID' value=''>
</td>
</tr>
</TFOOTER>
</table>
I have some problem with a function(below with part of my table for clarity).
The function is supposed to get the value that is stored in a hidden inputbox that lies in a hidden td-tag.
but it seems that I cant get hold of the hidden td-element.
the error states the my var itd is not an object??
lvwGrade_hdnSelectedRowID - is set with the value of the last clicked row
tbllvwGrade_r0 - rowID with name of the table + a incrementing number
hdnKey - I have one for each row that contains different value, therefor I put it in a hidden td-tag
what have I done wrong in the function?
function lvwGrade_getKey()
{
var sId='lvwGrade_hdnSelectedRowID';
alert('sid:'+sId); //shows "lvwGrade_hdnSelectedRowID"
var hdn = document.getElementById(sId);
alert('hdn.value:'+hdn.value); //shows "tbllvwGrade_r0"
var hdnName=hdn.value + "_Key";
alert('hdnname:'+hdnName); //shows "tbllvwGrade_r0_Key"
var itd = document.getElementById(hdnName); //should get the element of "tbllvwGrade_r0_key"
alert('itd.id:'+itd.id); //error td is not an object
var key=td.childNodes[0].value;
return key;
}
<tr ID='tbllvwGrade_r0' ondblclick='javascript:lvwGrade_saveRowID(this);javascript:opengrade(this,17420)'>
<td width='5' class='listbody'></td>
<td ID=tbllvwGrade_r0_c0 class='listbody'></td>
<td ID=tbllvwGrade_r0_c1 class='listbody'>N08020</td>
<td ID=tbllvwGrade_r0_c2 class='listbody'></td>
<td ID=tbllvwGrade_r0_c3 class='listbody'></td>
<td ID=tbllvwGrade_r0_c4 class='listbody'><0.07</td>
<td ID=tbllvwGrade_r0_c5 class='listbody'></td>
<td ID=tbllvwGrade_r0_c6 class='listbody'>19.0-21.0</td>
<td ID=tbllvwGrade_r0_c7 class='listbody'>32.0-38.0</td>
<td ID=tbllvwGrade_r0_c8 class='listbody'>2.00-3.00</td>
<td ID=tbllvwGrade_r0_c9 class='listbody'>Cu:3.0-4.0 Mn:<2.00 Nb:8xC-1.00 P :<0.045 S :<0.035 Si:<1.00 </td>
<td ID=tbllvwGrade_r0_ID' style='display:none'><input ID='hdnID' type='hidden' value=''></td>
<td ID=tbllvwGrade_r0_Key' style='display:none'><input ID='hdnKey' type='hidden' value='79356key'></td>
</tr>
</TBODY>
<TFOOTER>
<tr ID="tblfooter">
<td>
<input id='lvwGrade_hdnSelectedRowID' type='hidden' name='lvwGrade_hdnSelectedRowID' value=''>
</td>
</tr>
</TFOOTER>
</table>