【发布时间】:2014-05-12 16:45:14
【问题描述】:
我正在尝试执行here 发布的内容,但在我的情况下,我不得不对其进行一些修改,因为 MVC 视图在呈现时具有多个表单标签。我需要可以与现有文件输入同名的“文件”框。我可能还需要为每个新盒子添加新名称和描述,但还没有做到这一点。
我的观点:
<div id="dialog1" title="Upload Multiple Files">
<% using (Html.BeginForm("MyAction", "MyController", new { path = Model.FullPath }, FormMethod.Post, new { enctype = "multipart/form-data", id = "uploadsfrm" }))
{%>
<p>
<input type="file" id="file1" name="fileUpload" size="23" />
</p>
<p>
Title</p>
<input type="text" id="Text1" name="txtNiceName" style="width: 100%;"/>
<p>
Description</p>
<input type="text" id="Text2" name="txtDescription" style="width: 100%;"/>
<INPUT type="button" value="Add" onclick="addbox('file')"/>
<span id="addBoxes"> </span>
<p>
<input type="submit" value="Upload file" /></p>
<% } %>
</div>
脚本:
function addbox(type) {
var element = $("#uploadsfrm").createElement("input");
element.setAttribute("type", type);
element.setAttribute("value", type);
element.setAttribute("name", type);
var foo = $("#uploadsfrm").getElementById("addBoxes");
foo.appendChild(element);
}
当我单击添加按钮时,我在 Firebug 中遇到的错误是: “TypeError: $(...).createElement 不是函数”
谁能解释一下?提前致谢。
【问题讨论】:
标签: javascript jquery asp.net-mvc forms