相关文章
更多最近更新
更多用‘button’跟‘text’组合代替‘file’,选择文件后点‘submit’,‘file’的值被清空
2019-03-25 13:37|来源: 网路
各位大虾晚上好,我有个问题想请教你们,我想美化html的file外观,但貌似现在还不能用css直接设计,于是我在网上找了一个方法,就是用‘text’与‘button’组合来代替‘file’,可是在选择文件之后,点‘submit’是,它会自动把‘file’里面的值清空(ps:看这个情况时,可以先将‘file’的display设置成非none),代码如下:
<script language="javaScript">
function FileValue(fileValue,taskId)
{
var task = document.getElementById(taskId);
task.value = fileValue;
document.getElementById("data_file").value=task;
}
</script>
<body>
<input type="text" name="data_form" readonly class="form_text" style="width:300px;"/>
<input type="button" class="form_button" onclick="data_file.click();" value="test"> <p>
<input type="file" name="data_file" onchange="FileValue(this.value,'data_form')" style="display:block;"> <p>
<input type="submit" value="submit">
</body>
问题补充:
能给个例子吗
<script language="javaScript">
function FileValue(fileValue,taskId)
{
var task = document.getElementById(taskId);
task.value = fileValue;
document.getElementById("data_file").value=task;
}
</script>
<body>
<input type="text" name="data_form" readonly class="form_text" style="width:300px;"/>
<input type="button" class="form_button" onclick="data_file.click();" value="test"> <p>
<input type="file" name="data_file" onchange="FileValue(this.value,'data_form')" style="display:block;"> <p>
<input type="submit" value="submit">
</body>
问题补充:
能给个例子吗
相关问答
更多-
问题是IE不会让你通过javascript提交文件,用户必须点击文件输入。 这是一个已知的问题,在这里描述: When an file-input is opened via a scripted, forced click() event, IE won't let you submit the form. If you click the file-input via your own mouse (what we don't want), IE will let you submit the form ...
-
错字: submit_btn与submitbtn /////html ...
-
解 在这种情况下你必须使用sh -c : -exec sh -c "> {}" \; 用法示例 准备文件: $ echo hello > a1 $ cp a1 a2; cp a1 b1; cp a1 b2 $ ls -l total 16 -rw-r--r-- 1 ic ic 6 6. Aug 14:45 a1 -rw-r--r-- 1 ic ic 6 6. Aug 14:45 a2 -rw-r--r-- 1 ic ic 6 6. Aug 14:45 b1 -rw-r--r-- 1 ic ic 6 ...
-
至少部分已经回答了这个问题。 这是链接: 字段和FileUpload的表单验证 基本上,你创建一个不可见的textBox。 然后将触发器附加到“选择文件”按钮,该按钮为该文本框提供一个值。 然后,使用标准验证工具检查textBox的值,如果找到正确的值,则启用该按钮。 您还必须对doPost中的文件进行排序,以查看他们决定上传哪些文件,因为如果您尝试在空插槽上运行上载保存,则会抛出错误。 相反,您可以使用If语句来确保只尝试上传真实文件。 您可以通过运行e.parameter.fileUpload.name ...
-
我所做的是我用带载波波场的div来包装该领域,然后我可以做这样的事情 .carrier-wave-field input { color: red; /*or whatever you want to change*/ } What I do is I wrap the field with a div with the class carrier-wave-field, then I can do something like this .carrier-wave-field input { ...
-
在我修复了几个小错误之后,您的脚本似乎按照您的意图工作: 修正: ... var := trim(var, " `t`r`n") ; trim trailing LF/CR msgbox Text file will be named: %VAR%.txt ... run %A_ScriptDir%\%var%.txt ; added %'s to expand var ... 我的List.txt Alpha Beta Delta ...
-
如何禁用提交按钮,直到所有文本字段已满并选择文件(How to disable submit button until all text fields are full and file is selected)[2024-02-27]
尝试在这些字段上捕获事件并使用其他函数检查空值,请参阅下面的代码: $(':input').on('change keyup', function () { // call the function after // both change and keyup event trigger var k = checking(); // if value inc not 0 if (k) $('.submit').prop('disabled', true); // if value i ... -
如果要在选择文件后立即提交表单,请使用该输入的更改事件。 在脚本中 $(":file").change(function(e){ $("[name=myForm]").trigger('submit'); }); If you want to submit the form as soon as the file ...