一个简单的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, '');这种写法只能获取第一个点前面的内容。 谁知道百度贴吧是用哪种语言的脚本? 求高手指导淘宝商品快递费抓取! php url参数问题 smarty 的 foreach 中的 last 变量怎么访问? asp 购物车 输出数组中的 指定元素 显示图片之前,先把图片压缩后再显示,怎么做? 为什么在浏览器中无法正常显示中文? 这个计数器程序怎么不能用? 找不到sesiion文件 关于正则表达式的解释? 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, '');
这种写法只能获取第一个点前面的内容。