-2
我有两个下拉选项名称和值的许多形式,我想选择名称的选项是一个数组中的变量,像这样。如何选择具有多个下拉选项的给定行中特定下拉列表的值?
for (i = 0;i<noOfElements;i++)
{
var resultHtml = theModule.getHtml("rowformtemplate", {});
//load html of form with fields **name** and **value** as dropdown
$(section).append(resultHtml);
//append html to a div
var optValue = namearray[i];
//from list of optons this value should be selected
var form = $(section).find(".row-template");
//find all forms in the section
var row= form[form.length-1];
//select latest form
//How to select name field "name" of current row and set it to be optvalue which is a variaable something like this. but it selects name field of all form and sets it to optValue
$("select[name^='name'] option[value=" + optValue + "]").attr("selected","selected");
}
我停下来后,几行阅读,请张贴一些代码和适当的可读段落。 – seahorsepip