window.form1.Ring_wma_Path.value.Substring(window.form1.Ring_wma_Path.value.LastIndexOf("\") + 1)
在JS中,字符“\”是转义字符,在JS获得路径字符串前,你应该先对它作一定的处理,即应该把字符串中的“\”字符替换为双斜杠“\\”,两个斜杠在JS中才表示一个斜杠,这和C语言一样.

解决方案 »

  1.   


    你这个怎么写我不是很清楚,因为你给的资料并不多,我很难参详你参与一下下面这个看看,问题类似的:就是找出路径字符串中的文件名:<input type=text value="D:\Program Files\BitComet\rules\tracker.dat" name="filepath"> 
    <script>
    function getfilename(str){
    var s=str.split("\\\\");
    return s[s.length-1];
    }
    alert(getfilename(document.all.filepath.value.replace(/\\/g,'\\\\')));
    </script>
      

  2.   

    function t(objx,cc)
    {
    F='http://localhost/51wap/Admin_HIF/tl.aspx?n=' +objx +'&c=' +cc
    ddd.Filename=F
    //window.open(F)
    }
    <input name="Ring_wma_Path" type="text" id="Ring_wma_Path" style="width:220px;" ondblclick="javascript:ShowEdit(4)" value="11b13.wma" maxlength="300" /> 
                  &nbsp;<a href="javascript:ShowEdit(4)"><IMG src="image/uf.gif" border="0" alt="上传" title="上传"></a> 
                  <a href="javascript:t(window.form1.Ring_wma_Path.value,'04')"><IMG src="image/mms_log.gif" border="0" alt="试听" title="试听"></a>
    <OBJECT id="ddd" style="WIDTH: 0px; HEIGHT: 0px" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
    name="ddd" VIEWASTEXT>
    .</OBJECT>这样是可以试听音乐的,textbox里显示的是一个文件名,比如abc.mp3
    但是我现在想把textbox换成上传控件
    function t(objx,cc)
    {
    F='http://localhost/51wap/Admin_HIF/tl.aspx?n=' +objx +'&c=' +cc
    ddd.Filename=F
    //window.open(F)
    }<input name="Ring_wma_Path" type="File" id="Ring_wma_Path" style="width:220px;" ondblclick="javascript:ShowEdit(4)" value="11b13.wma" maxlength="300" /> 
                  &nbsp;<a href="javascript:ShowEdit(4)"><IMG src="image/uf.gif" border="0" alt="上传" title="上传"></a> 
                  <a href="javascript:t(window.form1.Ring_wma_Path.value,'04')"><IMG src="image/mms_log.gif" border="0" alt="试听" title="试听"></a>
    <OBJECT id="ddd" style="WIDTH: 0px; HEIGHT: 0px" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
    name="ddd" VIEWASTEXT>
    .</OBJECT>因为以前的textbox显示的是abc.mp3,但是现在用了上传控件后,地址变成了 e:\xxx\abc.mp3
    我现在想window.form1.Ring_wma_Path.value把这里的值怎么能让他得到的是abc.mp3,不知道我说清楚没有