获取关联单元格onchange的值

Get value for associated cell onchange

本文关键字:的值 onchange 单元格 关联 获取      更新时间:2023-09-26

我有一个.hta,它有一组在表中动态创建的下拉框。该表从json文件生成。该表看起来像(表中显然还有更多内容,但这给了你一个想法):

output +=
"<td style='display:none' name='expensive' style='background-color:#EDEDED'><center><input id='expensive_box' type='checkbox'></center></td>" + 
"<td style='display:none' name='cheap'><center><input id='cheap_box' type='checkbox'></center></td>" + 
"<td style='display:none' id='Spdropsyst' name='SPdropsyst'><select class='jumpmenu' name='SpRating' id='SpRating' onchange='writeRate()'><option id='blank' selected='selected'>...</option><option id='accepted' value=''>SP Accepted</option><option id='declined' value=''>SP Declined</option></select></td>";
output += 
"<td id='biz_name'>" + results[i]["Business Name"] + "</td>" +
"<td style='display:none' name='addressCol'>" + results[i]["Address"] + "</td>" + 
"<td><center>" + results[i]["City"] + "</center></td>" + 
"<td><center>" + results[i]["StateListing"] + "</center></td>"; 

然后用写入每一行

document.getElementById("占位符").innerHTML=输出;

每一行都会生成自己的下拉列表。onchange函数为:

function writeRate()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var write_id = "file to write to here";
alert('The information has been forwarded to the OON Map Team, Thank you!');
var s = fso.OpenTextFile(write_id, 8, true);
alert(write_id);
s.WriteLine(" ");
if (document.getElementById('cheap_box').checked){
s.WriteLine('cheap');
}
if (document.getElementById('expensive_box').checked){
s.WriteLine('expensive');
}
s.Close();
}

现在我要找的是,当x行上的框发生更改时,我希望它能获取同一行x的业务名称,并将其写入文件。因此,如果有人更改drop x,它将写出业务x,如果有人为drop y更改,它将写下业务y。

在生成表时,我将业务名称传递到一个数组中。所以我有:

spArray.push(results[i]["Business Name"];

我可以调用任何名称,但不能将名称与框关联起来。我该如何以最简单的方式完成这项工作?

通过使用数组spArray并使用它填充下拉列表来解决这个问题。因此,我没有动态创建一组下拉列表,而是有一个下拉列表,然后我可以轻松地从下拉列表中获取选定的值。问题解决了,我很开心。