朋友们,
我编写了以下 JavaScript 来确定用户当前在表格的哪一行。即他们单击了第 4 行上的选择列表。我需要行号然后获取同一行上字段的正确值,然后我可以对其执行一些进一步的处理。
这个 JavaScript 所做的是获取触发项的 id,例如 f02_0004 这告诉我第 4 行第 2 列中的选择列表已被选中。因此,我的 Javascript 仅获取行信息,即 0004,然后使用它来引用该行中的另一个字段,此时仅输出值以显示我具有正确的值。
<script language="JavaScript" type="text/javascript">
function cascade(pThis){
var row = getTheCurrentRow(pThis.id);
var nameAndRow = "f03_" + row;
var costCentre = $x(nameAndRow).value;
alert("the cost centre id is " + costCentre);
}
// the triggerItem has the name fxx_yyyy where xx is the column number and
// yyyy is the row. This function just returns yyyyy
function getTheCurrentRow(triggerItem){
var theRow = triggerItem.slice(4);
return theRow;
}
虽然这行得通,但我不禁觉得我必须重新发明轮子,或者,有内置的我可以使用,或者如果没有,可能有“更好”的方法?
如有需要,我使用 Apex 4.0
提前感谢您提供的任何内容。