我使用 MVC 有以下表单:
@using (Html.BeginForm())
{
<div class="editor-label">
@Html.LabelFor(m => m.Title)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.Title)
@Html.ValidationMessageFor(m => m.Title)
</div>
<div class="editor-label">
@Html.LabelFor(m => m.Description)
</div>
<div class="editor-field">
@Html.TextAreaFor(m => m.Description)
@Html.ValidationMessageFor(m => m.Description)
</div>
<div class="editor-label">
@Html.LabelFor(m => m.Icon)
</div>
<div class="editor-field">
@Html.RadioButtonFor(m => m.Icon, "http://maps.google.com/mapfiles/ms/icons/red-pushpin.png", new { @checked = "checked" }) <img src="http://maps.google.com/mapfiles/ms/icons/red-pushpin.png" alt="red pusphin" />
@Html.RadioButtonFor(model => model.Icon, "http://maps.google.com/mapfiles/ms/icons/red-pushpin.png") <img src="http://maps.google.com/mapfiles/ms/icons/blue-pushpin.png" alt="blue pushpin" />
</div>
}
如何使用 JavaScript 检索数据?
我尝试了以下方法,但似乎不起作用:
document.getElementsByName('Title').value;
最佳答案
关于javascript - 使用 Javascript 获取 MVC 表单数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23151811/