[thelist] JavaScript snafu (trying to replace characters in a string)

Chris George chrisg at gsnet.com
Wed Aug 1 12:17:02 CDT 2001


Hi everyone,

I've got this page where I need to dissect the URL and create a page
location.  I came up with some really bad JavaScript...

Essentially what I want to do is change Backhoe_Loaders to Backhoe
Loaders...

<script language="JavaScript">

var theURL = document.location+""
// case: 
http://www.gsnet.com/servlet/MachineListing/Equipment/Backhoe_Loaders/1_1445
.html
if (theURL!="") {
    var urlArray = theURL.split("/")
    var b = 2 // http://
    var name = urlArray[b+4]
    var cgname = replace(name,'_',' ') // here is where I tried to replace _
with a space, more like a sentence...
    var cat = urlArray[b+3];
}

</script>

JavaScript complains that cgname is undefined...

Is it? Isn't it?  What am I doing?  Where are my pants?

Any help would be awesome...

Chris.





More information about the thelist mailing list