Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-18-2005, 10:20 PM   PM User | #1
TravisMath
New Coder

 
Join Date: Mar 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
TravisMath is an unknown quantity at this point
Question Using JS with forms

Is there a way to get only part of an input value?
For example I have a file input and I need to only get the last part of it.

For example if they enter:

C:\Documents and Settings\Mike McDonald\My Documents\My Pictures\708d8b3face5f11b2acd82f5f6bbbd7e5295815.JPG

can I have the variable set to the thing after the last "\" mark. For instance in the above file place. could I have the variable set to 708d8b3face5f11b2acd82f5f6bbbd7e5295815.JPG

If so could you provide me with a code or a place to search for a code like this.

Thank You Very Much!
TravisMath is offline   Reply With Quote
Old 03-18-2005, 10:43 PM   PM User | #2
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
You could use the split function to return the last part of the string:
PHP Code:
<html>
<
head>
<
script type="text/javascript">
function 
parts()
{
    var 
path document.forms[0].path.value;
    var 
parts path.split("\\");
    var 
parts.length 1;
    
alert(parts[i]);

}
</script>
</head>
<body>
<form action="" method="">
<input type="text" name="path"><br>
<input type="button" name="but" value="Split" onclick="parts();">
</form>
</body>
</html> 
Good luck;
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:32 AM.


Advertisement
Log in to turn off these ads.