【发布时间】:2013-04-25 18:45:02
【问题描述】:
这是jsfiddle 代码handsontable 的链接。按下按钮时,数据集进入控制台。我的网页上有两段不同的 JavaScript 代码。其中之一包含handsontable。 如何将数据传输(转储)到属于不同脚本(而不是控制台)的数组?有没有办法创建一个所有脚本都可以看到的 static 数组(就像在Java中一样)?
方案如下:
<div id="mytable" class="handsontable"> </div>
<script>
// Here the user inserts the data to the handsontable. As she presses the button, data should go to the second piece of script.
</script>
...
<div id="target" class=""> </div>
<script>
//the target array is here, and it needs to be filled with the data from the above piece of script as the button is pressed.
</script>
【问题讨论】:
-
您是否尝试将这两个脚本结合起来?
-
@Pizdy 是的,我已经尝试过了。不幸的是,它无法完成,因为这两个部分是两个不同的 JQueries。它们是两个不同的类。
-
如何打开 jsfiddle?
-
@Kamil 转到链接,它会将您带到
handsontable网站,有一个指向jsfiddle的按钮 -
您可以创建一个表单,并使用 PHP 将数据提交到服务器,然后将它们发送回您的脚本,或者您可以使用 URL 中的数据。检查此链接boutell.com/newfaq/creating/scriptpass.html
标签: javascript arrays handsontable