我正在使用一个由数字文本框(Telerik)组成的网格。
让我告诉你这张照片,
现在你可以看到,这个网格有四列。在第3列,我有该文本框,该文本框负责触发事件。让我告诉你那个事件..
function CalculateReduceAmount(sender, eventArgs) {
debugger;
var unitPrice = sender._element.parentNode.parentNode.parentNode.cells[3].getElementsByTagName('input')[0].value;
var reduceAmt = eventArgs._newValue;
if (reduceAmt != "") {
if (!isNaN(reduceAmt)) {
if (parseFloat(reduceAmt) < parseFloat(unitPrice)) {
var reduceType = sender._element.parentNode.parentNode.parentNode.cells[1].getElementsByTagName('input')[2].value;
if (reduceType == 'Value') {
unitPrice = unitPrice - reduceAmt;
} else {
unitPrice = unitPrice - (unitPrice * reduceAmt) / 100;
}
}
}
}
}
现在我完全获得unitPrice,但无法获得reduceType。 例外:
无法读取未定义的属性“值”
我该如何解决?我无法从代码中获取radiobuttonlist
编辑:
sender._element.parentNode.parentNode.parentNode.cells 1返回
<table id="ctl05_rw_SetPrice_C_rgv_PriceByUoM_ctl00_ctl06_rdobtn_ReduceType" onclick="return clickfn(this);" style="width:100%;">
<tbody><tr>
<td><input id="ctl05_rw_SetPrice_C_rgv_PriceByUoM_ctl00_ctl06_rdobtn_ReduceType_0" type="radio" name="ctl05$rw_SetPrice$C$rgv_PriceByUoM$ctl00$ctl06$rdobtn_ReduceType" value="Percentage" checked="checked"><label for="ctl05_rw_SetPrice_C_rgv_PriceByUoM_ctl00_ctl06_rdobtn_ReduceType_0">%</label></td><td><input id="ctl05_rw_SetPrice_C_rgv_PriceByUoM_ctl00_ctl06_rdobtn_ReduceType_1" type="radio" name="ctl05$rw_SetPrice$C$rgv_PriceByUoM$ctl00$ctl06$rdobtn_ReduceType" value="Value"><label for="ctl05_rw_SetPrice_C_rgv_PriceByUoM_ctl00_ctl06_rdobtn_ReduceType_1">Value</label></td>
</tr>
</tbody></table>