在web里,用button取代<input type='file'>的问题 你这个控件只有visual studio中带了由。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <input type=file name='file1' size='15' style='display: none;'><br><input type='text' name='file2' id='file2'><input type=button name='brower' id='brower' style="width:83;height:24" value="浏览" onclick='document.all.file1.click(); document.all.file2.value=document.all.file1.value'> 就是把file藏起来,按了取触发那个file的click事件,呵呵 但是以孟子E章和我是大猫猫的方法,当在表单里有submit时,需要点击两下才能提交(先单击一下,鼠标从按钮移出,再单击一下才能提交),这是为什么?有方法解决吗? <form enctype="multipart/form-data"><input type="file" id="upfile" style="width=200px;"><span style="position:relative;left:-80px;width=80;"><input type=button onclick="upfile.click();" value=样式随你设></span><span style="position:relative;left:-80px;"><input type="submit" value="上传"></span></form>------------------试试我的方法~~~~~~~~~~~ 感兴趣,有方法解决吗?----------------------------但是以孟子E章和我是大猫猫的方法,当在表单里有submit时,需要点击两下才能提交(先单击一下,鼠标从按钮移出,再单击一下才能提交),这是为什么?有方法解决吗? <script>function UpLoadForm_Validator(pUpLoadForm){ if(document.all.UpLoadFile.value=="") { window.confirm("请选择上传的文档!"); pUpLoadForm.UpLoadFile.focus(); return false; } var strFileFormat=pUpLoadForm.UpLoadFile.value.match(/^(.*)(\.)(.{1,8})$/)[3];//检查上传文件格式 strFileFormat=strFileFormat.toUpperCase(); if(strFileFormat=="DOC"||strFileFormat=="DOT") { } else { window.confirm("只能上传.Doc和.Dot,请重新选择!"); return false; } return true;}</script><form method="POST" enctype="multipart/form-data" action="" onsubmit="return UpLoadForm_Validator(this)" laguage="JavaScript" name="UpLoadForm"><input type="file" name="UpLoadFile" id="UpLoadFile" style="visibility:hidden;"><input type=button onclick="UpLoadFile.click();" style="background-color:#336699"><input type="submit" value="上传" name="UpLoadButton"></form> gjd111686(数字金刚)-----写的不错,可惜不对题。不是要上传,是要返回路径,且提交后可以在页面中保留路径,孟子E章已解决一大半,只是要按两次按钮。 <input type="file" name="UpLoadFile" id="UpLoadFile" style='display:none' ><input type=button onclick="UpLoadFile.click();">可以的 patchclass(黑翼)--请先测试一下gjd111686(数字金刚)的源码,再看能否提交后可以在页面中保留路径.不是要上传,是要返回路径.用户选一次路径,提交,返回的页面中,原路径还显示.先看看net_lover(孟子E章) 的源码,你就明白了. 这个问题我搜索了一遍,一共有两个办法(不算ActiveX).但都不是最佳.一个是net_lover(孟子E章)的,但当在表单里有submit时,需要点击两下才能提交.另一个是woyingjie(killerj.style.display == "none";)(隐身中..........)的,这个方法出现过多次,但页面很难摆齐.有没有高手可以解决? ???你在点第一次 的时候自动触发第二次提交不久可以了用formname.submit() 怎么自动触发?在form onsubmit()中?好象不行。你试过没? 如果把file field变成服务端运行,好像不能正确返回,麻烦哪位高人指点一下,让file field变成服务端运行也好用,(按钮显示为样式随你设)<form enctype="multipart/form-data"><input type="file" id="upfile" style="width=200px;"><span style="position:relative;left:-80px;width=80;"><input type=button onclick="upfile.click();" value=样式随你设></span><span style="position:relative;left:-80px;"><input type="submit" value="上传"></span></form> 接上贴;当按“上传“按钮后,file field中的值就没有拉,而且还要按两次才能回发。在后台程序中得到的upfile.PostedFile.ContentLength老是0,根本没有传回来。 为了少走些弯路,还希望各位给提点意见!!! scrollHeight的问题 JS获取值问题。请教了 高分求助,在线等,急! javascript 新手求助,关于innerHTML 怎么样才能做一个置顶的层? 高分!!!请高手指点!!!用jvavascript在asp.net中写个新建infopath文件 让文本框失效 得到<textarea>表单里面内容的属性是什么来着? JS打开新页问题<select name="select" onChange="document.location.href=this.value">这个只能在本页打开 关于滚动条
<br><input type='text' name='file2' id='file2'>
<input type=button name='brower' id='brower' style="width:83;height:24" value="浏览" onclick='document.all.file1.click(); document.all.file2.value=document.all.file1.value'>
<input type="file" id="upfile" style="width=200px;">
<span style="position:relative;left:-80px;width=80;">
<input type=button onclick="upfile.click();" value=样式随你设>
</span>
<span style="position:relative;left:-80px;">
<input type="submit" value="上传">
</span>
</form>
------------------
试试我的方法~~~~~~~~~~~
----------------------------
但是以孟子E章和我是大猫猫的方法,当在表单里有submit时,需要点击两下才能提交(先单击一下,鼠标从按钮移出,再单击一下才能提交),这是为什么?有方法解决吗?
function UpLoadForm_Validator(pUpLoadForm)
{
if(document.all.UpLoadFile.value=="")
{
window.confirm("请选择上传的文档!");
pUpLoadForm.UpLoadFile.focus();
return false;
}
var strFileFormat=pUpLoadForm.UpLoadFile.value.match(/^(.*)(\.)(.{1,8})$/)[3];//检查上传文件格式
strFileFormat=strFileFormat.toUpperCase();
if(strFileFormat=="DOC"||strFileFormat=="DOT")
{
}
else
{
window.confirm("只能上传.Doc和.Dot,请重新选择!");
return false;
}
return true;
}</script>
<form method="POST" enctype="multipart/form-data" action="" onsubmit="return UpLoadForm_Validator(this)" laguage="JavaScript" name="UpLoadForm">
<input type="file" name="UpLoadFile" id="UpLoadFile" style="visibility:hidden;">
<input type=button onclick="UpLoadFile.click();" style="background-color:#336699">
<input type="submit" value="上传" name="UpLoadButton">
</form>
<input type=button onclick="UpLoadFile.click();">可以的
你在点第一次 的时候自动触发第二次提交不久可以了
用
formname.submit()
<form enctype="multipart/form-data">
<input type="file" id="upfile" style="width=200px;">
<span style="position:relative;left:-80px;width=80;">
<input type=button onclick="upfile.click();" value=样式随你设>
</span>
<span style="position:relative;left:-80px;">
<input type="submit" value="上传">
</span>
</form>