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

.jeff jeff at members.evolt.org
Wed Aug 1 12:30:54 CDT 2001


chris,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Chris George
>
> 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...
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

start here with javascript created versions of cgi variables:

http://members.evolt.org/jeff/code/js_cgi_variables/index.cfm

from there you can dissect the cgi.path_info string which would be this in
your case:

/servlet/MachineListing/Equipment/Backhoe_Loaders/1_1445.html

a list function might be useful here:

function ListGetAt(list, position, delimiter)
{
  if(delimiter == null) delimiter = ',';
  list = list.split(delimiter);
  if(list.length > position)
    return list[position];
  else
    return 'undefined';
}

list and position are required arguments.  delimiters is optional, but
defaults to comma so you'll wanna pass it a slash.

var cgname = ListGetAt(cgi.path_info, 4, '/');

good luck,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/






More information about the thelist mailing list