PDA

View Full Version : سوال: اضافه کردن@Html.DropDownList با jquery به فرم



Iran58
شنبه 25 بهمن 1399, 16:00 عصر
سلام
من کد زیر را نوشته ام

<script>
$('#addTr').on('click',
function () {
var number = $('#dt tr').length;
$('#dt').append('<tr><td>' +
number + '</td><td>@Html.DropDownList("TypeId", new SelectList(ViewBag.Type, "TypeId", "Name"), "",
new { @class = "form-control", style = "width:100%" })</td><td> <a id="addTr" class="btn btn-warning rounded mr-0 fileDel"><span class="font-weight-light p-1" style="font-size: 14px; color: #fff">حذف سطر</span><i class="fal fa-trash"></i></a></td></tr>');


});


</script>

ارور زیر را می دهدUncaught SyntaxError: Invalid or unexpected token
باید کد را چگونه بنویسم تا مشکلم برطرف شود

moslem.hady
یک شنبه 26 بهمن 1399, 10:00 صبح
$('#addTr').on('click',
function () {
var number = $('#dt tr').length;
$('#dt').append('<tr><td>' +
number + '</td><td>@Html.DropDownList("TypeId", new SelectList(ViewBag.Type, "TypeId", "Name"), "", new { @class = "form-control", style = "width:100%" })</td><td> <a id="addTr" class="btn btn-warning rounded mr-0 fileDel"><span class="font-weight-light p-1" style="font-size: 14px; color: #fff">حذف سطر</span><i class="fal fa-trash"></i></a></td></tr>');


});

Iran58
یک شنبه 26 بهمن 1399, 13:54 عصر
$('#addTr').on('click',
function () {
var number = $('#dt tr').length;
$('#dt').append('<tr><td>' +
number + '</td><td>@Html.DropDownList("TypeId", new SelectList(ViewBag.Type, "TypeId", "Name"), "", new { @class = "form-control", style = "width:100%" })</td><td> <a id="addTr" class="btn btn-warning rounded mr-0 fileDel"><span class="font-weight-light p-1" style="font-size: 14px; color: #fff">حذف سطر</span><i class="fal fa-trash"></i></a></td></tr>');


});
سلام
ارور زیر را می دهد
Uncaught SyntaxError: Invalid or unexpected token