...

View Full Version : textbox remove data upto 2nd to last /



scroots
07-29-2002, 08:53 PM
if i have a textbox with the contents http://www.blah.com/b/n/g/g/gg/h/d/
how usnig javascript can i make it when a button is pressed change to:
http://www.blah.com/b/n/g/g/gg/h/
and then when the button is pressed again it changes to:
http://www.blah.com/b/n/g/g/gg/

thanks in advance

scroots

tamienne
07-29-2002, 09:35 PM
function parentDirectory(remdir) {
remdir = remdir.substring(0,remdir.lastIndexOf("/")-1);
remdir = remdir.substring(0,remdir.lastIndexOf("/")+1);
return remdir;
}

scroots
07-29-2002, 09:39 PM
how would i call the function from a button?

scroots

adios
07-29-2002, 09:43 PM
<html>
<head>
<title>untitled</title>
</head>
<body>
<form>
<input type="text" name="path" size="36" value="http://www.blah.com/b/n/g/g/gg/h/d/">
<input type="button" value="One Less Dir"
onclick="path.value=path.value.replace(/\w+\/$/, '')">
<input type="reset">
</form>
</body>
</html>

scroots
07-30-2002, 10:18 PM
thank you so much i know understand.
when its explained i can learn and not just copy and paste.

scroots



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum