用正则表达式,怎么把input type="file"中的路径中的"\"转换成"/"?
<body>
<form name= "oImg " action= " ">
<table>
<tr>
<td>
<input type= "file " name= "OBJIMG/IMGLG " size= "30 ">
</td>
</tr>
</table>
<input type= "button " value= "提交 " onclick= "javascript:tg(); ">
</form>
</body>
</html>
<script language= "javascript ">
String.prototype.stripHTML=function(){
var reTag=/((?:.+)\{1}(?:.+))+?/gi;
return this.replace(reTag, "/ ");
}
function tg()
{
var frm=document.oImg;
var typOne=frm.elements( "OBJIMG/IMGLG ").value;
var typTwo=typOne.stripHTML();
alert(typTwo);
return;
frm.elements( "OBJIMG/IMGLG ").value=typTwo;
frm.action= "qxOne.pr.oImg.do ";
frm.submit();
}
顺面问一下,怎么给回答问题的同志加分,??因为我以前都没给辛苦回答我问题的人加过分呢
------解决方案-------------------- <body>
<script language= "javascript ">
function tg(){
var frm=document.oImg;
var typOne=frm.elements[ "OBJIMG/IMGLG "].value;
var typTwo=typOne;
typTwo = typTwo.replace(/\\/ig, "/ ");
alert(typTwo);
return;
// frm.elements( "OBJIMG/IMGLG ").value=typTwo; 不能对file赋值的。
// frm.action= "qxOne.pr.oImg.do ";
// frm.submit();
}
</script>
<form name= "oImg " action= " ">
<table>
<tr>
<td>
<input type= "file " name= "OBJIMG/IMGLG " size= "30 ">
</td>
</tr>
</table>
<input type= "button " value= "提交 " onclick= "tg(); ">
</form>
</body>
</html>