...

View Full Version : getting part of a value



sushestvo
01-17-2006, 09:32 PM
if i have a value var1 that is something like "C:\path\filename.jpg"
how can I only display filename.jpg?
pretty much look till first "\" from the right.
any help would be appreciated.

arnyinc
01-17-2006, 09:55 PM
<html>

<head>
<script language="javascript">

fullpath="C:\\path\\filename.jpg";

function showfile(currpath){
slashpos=currpath.lastIndexOf("\\");
filename=currpath.substring(slashpos+1, currpath.length);
alert(filename);
}
</script>
</head>

<body onload="showfile(fullpath);">

</body>

</html>


edit: I forgot to escape the backslashes in the fullpath variable.

sushestvo
01-17-2006, 10:47 PM
thank you thank you thank you



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum