次のように、ビューに dropDownListFor があります。
`@Html.DropDownListFor(x => x.idResponsaveis, Model.responsaveis)
<input type='button' value='Adicionar' onclick='adicionarResponsavel()' class='btn' />`
そして、ユーザーが adicionarResponsavel() をクリックするたびに、複数の dropDownList を追加する必要があります。
私のJavaScriptコードは次のとおりです。
function adicionarResponsavel(){
var div = document.getElementById('listaResponsaveis');
var node = document.createElement('div');
node.setAttribute('id', 'div' + quantity);
node.appendChild('@Html.DropDownListFor(x => x.idResponsaveis, Model.responsaveis)');
div.appendChild(node);
}
エラーのある特定の行は次のとおりです。
node.appendChild('@Html.DropDownListFor(x => x.idResponsaveis, Model.responsaveis)');