一个简单的js 救助 急急急!! 就是 比如两个文本框 第一个是 文件路径/文件名.扩展名第二个文本框 自动显示 文件名 就可以了 谢谢就是 第一个文本框显示 d:/cyc.rar第二个文本框用js 直接显示 cyc 并且可以编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script>function c(fn){ t = fn.split("\\"); document.getElementById('name').value = t[t.length-1];}</script><input type="file" id="image" onpropertychange="c(this.value)"><input type="text" id="name"> 把“onpropertychange”改为“onchange” "d:/cyc.rar".split("/")[1].split(".")[0] 就是 比如两个文本框 第一个是 文件路径/文件名.扩展名 第二个文本框 自动显示 文件名 就可以了 谢谢 就是 第一个文本框显示 d:/cyc.rar 第二个文本框用js 直接显示 cyc 并且可以编辑 上面的 都不对啊 其实第一个文本框是 上传组件 一个文本框 一个按钮的那种 谢谢 应该如何改一下 建议你用 ajax 从服务器获得文件的信息 再作分析 <script> function c(fn) { t = fn.split( "\\ "); document.getElementById( 'name ').value = t[t.length-1]; } </script> <input type= "file " id= "image " onpropertychange= "c(this.value) "> <input type= "text " id= "name "> 这段代码 有时候可以获得 但是 不是很好用阿 帮我看看是不是有什么问题 ,谢谢 大家了 8楼的办法应该也是可以的 不过要看你实现什么功能了:<script>function c(fn){ t = fn.split("\\"); document.getElementById('name').value = t[t.length-1];}</script><input type= "file" id= "image" onchange="c(this.value) "><input type= "text" id= "name"> <script>function c(fn){ t = fn.split("\\"); document.getElementById('name').value = t[t.length-1];}</script><input type= "file" id= "image" onchange="c(this.value) "><input type= "text" id= "name"> 靠 csdn 的编辑器搞什么 怎么老加没用的 空格 中间那一行改成 document.getElementById('name').value = t[t.length-1].replace(/\.(.*)/g, ''); 就可以了 <script>function cn(fn){ t = fn.split("\\"); t = t[t.length-1].split("."); n = new Array(); for(c=0; c<t.length-1; c++) n[n.length]=t[c]; document.getElementById('name').value = n.join(".");}</script><input type="file" id="image" onchange="cn(this.value)"><input id="name"> <script>function cn(fn){ t = fn.split("\\"); t = t[t.length-1].split("."); n = new Array(); for(c=0; c<t.length-1; c++) n[n.length]=t[c]; document.getElementById('name').value = n.join(".");}</script><input type="file" id="image" onchange="cn(this.value)"><input id="name"> <script> function cyc(filename) { t1= filename.lastIndexOf("."); t2= filename.lastIndexOf("\\"); t3 = filename.substring(t2+1, t1); document.getElementById('name').value=t3; }</script> <body><input type= "file" id= "image" onchange= "cyc(this.value) "> <input type= "text" id= "name"> </body>搞定了 呵呵 document.getElementById('name').value = t[t.length-1].replace(/\.(.*)/g, ''); 如果文件名有两个点怎么办?t[t.length-1].replace(/\.(.*)/g, '');这种写法只能获取第一个点前面的内容。 为什么在同一个页面session在上半部可以得到,而下半部得不到?请教高手。 JavaScript如何读取php设置的cookie 我想问下关于PHP的模板引擎问题!!!! xuzuning(唠叨),发现你对图片处理比较有研究,近来帮忙领100分 关于上传图片出现马赛克现象!!急呀!! 怎么让复选框只读,但是这个值又是需要传递的 我对PHP版要提建议.... 不好意思忘了html里全屏是哪个了,打扰一下? 高手来解释一下md5()加密的原理,md5()加密的东西是否唯一呢? 在线急等,大侠们请帮忙~~~ 关于正则表达式的解释? MySQL能承担多大的负载?
function c(fn)
{
t = fn.split("\\");
document.getElementById('name').value = t[t.length-1];
}
</script>
<input type="file" id="image" onpropertychange="c(this.value)">
<input type="text" id="name">
第二个文本框 自动显示 文件名 就可以了 谢谢
就是 第一个文本框显示 d:/cyc.rar
第二个文本框用js 直接显示 cyc 并且可以编辑 上面的 都不对啊 其实第一个文本框是 上传组件 一个文本框 一个按钮的那种 谢谢 应该如何改一下
function c(fn)
{
t = fn.split( "\\ ");
document.getElementById( 'name ').value = t[t.length-1];
}
</script>
<input type= "file " id= "image " onpropertychange= "c(this.value) ">
<input type= "text " id= "name ">
这段代码 有时候可以获得 但是 不是很好用阿 帮我看看是不是有什么问题 ,谢谢 大家了
function c(fn)
{
t = fn.split("\\");
document.getElementById('name').value = t[t.length-1];
}
</script>
<input type= "file" id= "image" onchange="c(this.value) ">
<input type= "text" id= "name">
function c(fn)
{
t = fn.split("\\");
document.getElementById('name').value = t[t.length-1];
}
</script>
<input type= "file" id= "image" onchange="c(this.value) ">
<input type= "text" id= "name">
function cn(fn)
{
t = fn.split("\\");
t = t[t.length-1].split(".");
n = new Array();
for(c=0; c<t.length-1; c++) n[n.length]=t[c];
document.getElementById('name').value = n.join(".");
}
</script>
<input type="file" id="image" onchange="cn(this.value)">
<input id="name">
{
t = fn.split("\\");
t = t[t.length-1].split(".");
n = new Array();
for(c=0; c<t.length-1; c++) n[n.length]=t[c];
document.getElementById('name').value = n.join(".");
}</script><input type="file" id="image" onchange="cn(this.value)">
<input id="name">
function cyc(filename)
{
t1= filename.lastIndexOf(".");
t2= filename.lastIndexOf("\\");
t3 = filename.substring(t2+1, t1);
document.getElementById('name').value=t3;
}
</script> <body>
<input type= "file" id= "image" onchange= "cyc(this.value) ">
<input type= "text" id= "name">
</body>搞定了 呵呵
t[t.length-1].replace(/\.(.*)/g, '');
这种写法只能获取第一个点前面的内容。