繁体   English   中英

通过可变形式的JavaScript

[英]pass variable form javascript

有一个隐藏的字段想在图形中使用该字段的值。 这是可能的? 下面是我使用的代码示例。

<input type="hidden" name="valor" id="valor" value="20" />


window.onload = function () {
var teste = (document.getElementById("valor").value);
dataPoints: [
{ label: "apple",  y: 10  },
{ label: "grape",  y: teste  }]

谢谢

您可以按照建议有效地获得价值。

您的代码不起作用,因为您只需要关闭函数括号即可:

window.onload = function () {
  var teste = document.getElementById("valor").value;
  dataPoints: [
    { label: "apple",  y: 10  },
    { label: "grape",  y: teste  }
  ];
} // <= here

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM