HTML/JavaScript/NetSuite 函数得到不正确的结果
HTML/JavaScript/NetSuite Function Getting Incorrect Results
我有内联 'html/javascript' ,它通过保存的搜索结果列(循环)上的公式(文本)字段注入浏览器。换句话说,这会为结果列中的每一行创建一个按钮,该按钮将针对特定的 line/record(即 internalid)执行 javaScript。 虽然按钮链接正常工作(即导航到正确的记录),但 JavaScript 警报结果为所有按钮点击行生成相同的 {internalid}:
'<html>
<a target="_blank" id="Link" href="https://website.com/rectype=142&id='||{internalid}||'">
<button id="Button" type="button" onclick=test();> Check-In
</button>
</a>
<script>
function test() {var x = document.getElementById("Link").href; alert(x);}
</script>
</html>'
当前警报结果:
第 1 行 [签到] 按钮单击警报 = https://website.com/rectype=142&id=157
第 2 行 [签到] 按钮单击警报 = https://website.com/rectype=142&id=157
所需的警报结果:
第 1 行 [签到] 按钮单击警报 = https://website.com/rectype=142&id=157
第 2 行 [签到] 按钮单击警报 = https://website.com/rectype=142&id=158
第 3 行 [签到] 按钮单击警报 = https://website.com/rectype=142&id=159
更新:需要 href 解析的任何结果,以便将其传递给脚本测试函数。
使用 {internalid}
作为 <a>
元素 ID 的一部分。
我不熟悉这种语法,但我相信它看起来像这样:
<a target="_blank" id="Link'||{internalid}||'" href="https://website.com/rectype=142&id='||{internalid}||'">
那么您的函数可能如下所示:
function test() {var x = document.getElementById("Link'||{internalid}||'").href; alert(x);}
这假定您的函数可以访问 '||{internalid}||'
。如果没有,您也许可以将其传递给函数。
我有内联 'html/javascript' ,它通过保存的搜索结果列(循环)上的公式(文本)字段注入浏览器。换句话说,这会为结果列中的每一行创建一个按钮,该按钮将针对特定的 line/record(即 internalid)执行 javaScript。 虽然按钮链接正常工作(即导航到正确的记录),但 JavaScript 警报结果为所有按钮点击行生成相同的 {internalid}:
'<html>
<a target="_blank" id="Link" href="https://website.com/rectype=142&id='||{internalid}||'">
<button id="Button" type="button" onclick=test();> Check-In
</button>
</a>
<script>
function test() {var x = document.getElementById("Link").href; alert(x);}
</script>
</html>'
当前警报结果:
第 1 行 [签到] 按钮单击警报 = https://website.com/rectype=142&id=157
第 2 行 [签到] 按钮单击警报 = https://website.com/rectype=142&id=157
所需的警报结果:
第 1 行 [签到] 按钮单击警报 = https://website.com/rectype=142&id=157
第 2 行 [签到] 按钮单击警报 = https://website.com/rectype=142&id=158
第 3 行 [签到] 按钮单击警报 = https://website.com/rectype=142&id=159
更新:需要 href 解析的任何结果,以便将其传递给脚本测试函数。
使用 {internalid}
作为 <a>
元素 ID 的一部分。
我不熟悉这种语法,但我相信它看起来像这样:
<a target="_blank" id="Link'||{internalid}||'" href="https://website.com/rectype=142&id='||{internalid}||'">
那么您的函数可能如下所示:
function test() {var x = document.getElementById("Link'||{internalid}||'").href; alert(x);}
这假定您的函数可以访问 '||{internalid}||'
。如果没有,您也许可以将其传递给函数。