是否可以清除struts2文件输入标记?
我正在使用Struts2进行web应用程序开发。我有一个特别的问题,我甚至在谷歌搜索后也找不到解决办法 我有3个标签,每个标签上都有一个超链接或按钮,如果之前选择了任何内容,则必须使用该标签清除文件路径。在线找到的解决方案是重置表单。。但是,所有的s:file标记都将被清除,因为所有标记都需要采用相同的形式是否可以清除struts2文件输入标记?,struts2,tags,file-io,Struts2,Tags,File Io,我正在使用Struts2进行web应用程序开发。我有一个特别的问题,我甚至在谷歌搜索后也找不到解决办法 我有3个标签,每个标签上都有一个超链接或按钮,如果之前选择了任何内容,则必须使用该标签清除文件路径。在线找到的解决方案是重置表单。。但是,所有的s:file标记都将被清除,因为所有标记都需要采用相同的形式 有没有办法在单击时清除单个文件输入???一个类似于我们所用的解决方案是删除输入元素并在其位置创建一个同名的新输入元素 编辑:下面是我举的一个例子 <script type="text/
有没有办法在单击时清除单个文件输入???一个类似于我们所用的解决方案是删除输入元素并在其位置创建一个同名的新输入元素 编辑:下面是我举的一个例子
<script type="text/javascript">
function clearFoo() {
var inp = document.getElementById("foo");
var parent = inp.parentNode;
// Create the new input element.
// Copy over any attributes you need.
var newInp = document.createElement("input");
newInp.type = "file";
newInp.name = inp.name;
// Replace the old node with the new node.
parent.insertBefore(newInp, inp);
parent.removeChild(inp);
// The new node is the new "foo".
newInp.id = "foo";
}
</script>
<s:file id="foo" name="foo"/>
<button onclick="clearFoo();">Click</button>
函数clearFoo(){
var inp=document.getElementById(“foo”);
var parent=inp.parentNode;
//创建新的输入元素。
//复制所需的任何属性。
var newInp=document.createElement(“输入”);
newInp.type=“文件”;
newInp.name=inp.name;
//用新节点替换旧节点。
parent.insertBefore(newInp,inp);
父母。removeChild(inp);
//新节点是新的“foo”。
newInp.id=“foo”;
}
点击
是否可以使用struts标签??有什么想法吗?:-)您只需在s:file
中添加一个id
属性即可。我添加了一个示例。