我有一个函数可以从xul文件(假设是tree.xul)中获取所选复选框的值。在另一个XUL文件中,有文本框,我想在其中传递所选复选框(例如textbox.xul)的值(标签值)。
最初,我从"tree.xul“文件中打开"textbox.xul”文件。当我选中复选框值并单击按钮将值传递给另一个xul文件(“textbox.xul”)时。
我在"textbox.xul“文件中有一个文本框,我想将复选框的值传递给这个文本框。
<textbox id="ali" value=""/>
<button label="Contacts" onclick="DisplayContacts();"/>在我的脚本中,我尝试这样做,但它不起作用,我还包括了这个小代码函数
window.close();
传递值后关闭窗口(“tree.xul”)。
我是否必须使用数组来存储变量的所有值?
我正在尝试使用Mozilla对话框中的解释,但它不起作用。
function get() { // check the alignment on a number of cells in a table.
var table = document.getElementById("box");
var cells = table.getElementsByTagName("checkbox");
for (var i = 0; i < cells.length; i++)
{
var cell = cells[i];
if(cell.checked) {
alert(cell.getAttribute("label"));
var x = cell.getAttribute("label");
x = window.arguments[0];
// or cell.label
}
}
window.close();
}这是动态创建的复选框值的代码:
function choose()
{
//alert('hi');
var tree = document.getElementById('myTodoListTree');
for (var i = 0; i < tree.view.rowCount; i++) {
if (tree.view.getCellValue(i, tree.columns.getColumnAt(0)) == 'true'){
var empty = " ";
var contact = (tree.view.getCellText(i, tree.columns.getNamedColumn("name"))+ empty+
tree.view.getCellText(i, tree.columns.getNamedColumn("lastname"))+ empty+ "Contacts:");
var ggmail = tree.view.getCellText(i, tree.columns.getNamedColumn("gmail"));
var yyahoo = tree.view.getCellText(i, tree.columns.getNamedColumn("yahoo"));
var existingEl = document.getElementById('box');
var capt = document.createElement('groupbox');
existingEl.appendChild(capt);
var captionEl = document.createElement('caption');
capt.appendChild(captionEl);
captionEl.setAttribute('label', contact );
captionEl.setAttribute('style', 'color: blue;');
var existing = document.getElementById('box');
var checkbox = document.createElement('checkbox');
capt.appendChild(checkbox);
checkbox.setAttribute('label', ggmail );
checkbox.setAttribute('style', 'color: green;');
var existing = document.getElementById('box');
var checkbox = document.createElement('checkbox');
capt.appendChild(checkbox);
checkbox.setAttribute('label', yyahoo);
checkbox.setAttribute('style', 'color: green;');
}
}
return arr;
} 在这里,用户选择"tree.xul“文件中的复选框,我有按钮(”function()“)将值添加到"texbox.xul”窗口的文本框中。
这是从text-box.xul文件中打开tree.xul的函数:
function DisplayContacts()
{
var returnValues = { out: null };
window.openDialog("chrome://hello/content/sundayevening2.xul","sundayevening2","", returnValues);
}请帮助我将这些值传递给另一个XUL窗口中的文本框。
谢谢你。
发布于 2011-08-24 08:42:09
您可能想使用这样的东西:向XUL中的对话框传递额外的参数
这提供了一种在xul文件之间传递值的简单方法。
对于您的问题,您可以在textbox.xul中这样做。这将打开tree.xul和额外的参数returnValues。
var returnValues = { out: null };
window.openDialog("tree.xul", "tree", "modal", returnValues);注意:modal是必需的。
接下来,在tree.xul中存储要传递给textbox.xul的所有值(让我们称之为x),如下所示:
window.arguments[0].out = x注window.argument指的是returnValues
现在,您可以访问textbox.xul中的x值(在您的示例中是标签的名称),如下所示:
var labels = returnValues.out;基本上,
https://stackoverflow.com/questions/7172333
复制相似问题