【发布时间】:2017-03-12 16:43:34
【问题描述】:
我得到了用于删除属性的 HttpPost:
[HttpPost]
public void RemoveProperty(int id)
{
propertyManager.Delete(id);
Response.Redirect("EditProperties");
}
在我的 cshtml 文件中,我得到了组合框,我需要获取选定的选项并将其作为 id 传递给 removeproperty,我的 cshtml 部分:
<form action="@Url.Action("RemoveProperty", "Admin")" method="post" id="remove_property">
<div class="form-group">
<h3>Remove Property</h3>
@*<input name="id" value="" id="removedid" />*@
<select class="form-control" id="prop_id" name="id">
@foreach (var prop in Model)
{
<option value="Characteristic_Id">@prop.Id</option>
}
</select>
</div>
<button onclick="" type="submit" class="btn btn-danger">Remove</button>
</form>
我知道如何使用 jquery 从选定的组合框中获取文本:
$("#prop_id option:selected").text(); 但问题是如何将这个参数传递给表单??
【问题讨论】:
-
同理,使用表单及其属性:
$( "form" ).attr( "action", "new.url" );
标签: javascript html css url