動的に生成されたフォームのすべてのフォームフィールドのクローンを作成しようとしています。このフォームには、1つ以上の選択アイテムを含めることができます。唯一の問題は、ユーザーが別の値を選択した後、選択したアイテムの値を複製できないことです。
次のコードを試しました。
//Arguments: "name"s of forms to submit.
//First argument: the form which according to its "action" all other forms will be submitted.
//Example: mergeForms("form1","form2","form3","form4")
function mergeForms() {
var forms = [];
$.each($.makeArray(arguments), function(index, value) {
forms[index] = document.forms[value];
});
var targetForm = forms[0];
$.each(forms, function(i, f) {
if (i != 0) {
$(f).find('input, select, textarea')
.clone()
.hide()
.appendTo($(targetForm));
}
});
誰かがこの問題で私を助けてくれることを願っています。