Forums
This topic is locked
JavaScript Guru required
Posted 21 Jan 2002 04:46:33
1
has voted
21 Jan 2002 04:46:33 Owen Eastwick posted:
This is driving me nuts: <img src=../images/dmxzone/forum/icon_smile_angry.gif border=0 align=middle>I have a browse to file box on my form from which a user can select an image to upload. When the user clicks the browse button I want to keep just the file name and the extension like : MyImage.jpg. So I've set up an onChange event which calls the UpdateField function. What I want to do is strip off every thing before the last backslash "\" then copy this to a hidden field and store just the file name in a database field.
The problem is I can't find a way of referencing the backslash, you cant use <b>varCharAt = varArticle.lastIndexOf("\"</b> 'cos backslash is an escape character so it screws up.
This is a bit of test code, where I've tried referencing the characte by its code, but still no joy.
function UpdateField(){
varArticle = "C:\MyPics\WebImages\MyImage.jpg";
varString = String.fromCharCode(92);
varCharAt = varArticle.lastIndexOf(varString) + 1;
varFile = varArticle.slice(varCharAt);
alert("Character = " + varString + "\nCharacter at = " + varCharAt + "\nFile = " + varFile);
}
Does anyone know how to solve this?
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Edited by - oeastwick on 21 Jan 2002 05:04:56
Replies
Replied 23 Jan 2002 03:21:21
23 Jan 2002 03:21:21 Owen Eastwick replied:
Anyone<img src=../images/dmxzone/forum/icon_smile_question.gif border=0 align=middle>
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo