Health 2007 - Debt Consolidation - Rome hotels - VeraciTek, Inc. - We Build Websites - Internet Advertising

PDA

View Full Version : Error in Code


Weirfire
Jun 11th 2007, 7:30 am
Can anyone see what the error is in the code below? My Javascript skills only stretch so far.

<script type='text/javascript'>

function explodeArray(item,delimiter) {
tempArray=new Array(1);
var Count=0;
var tempString=new String(item);

while (tempString.indexof(delimiter)>0) {
tempArray[Count]=tempString.substr(0,tempString.indexof(delimiter));
tempString=tempString.substr(tempString.indexof(delimiter)+1,tempString.length-tempString.indexof(delimiter)+1);
Count=Count+1
}

tempArray[Count]=tempString;
return tempArray;
}

function get_filename(full_path) {

parts = explodeArray(full_path,'/');

var num_items = parts.length;

return parts[(num_items-1)];

}

</script>

frankcow
Jun 11th 2007, 7:45 am
It would help if you'd post the error message you're getting...

Mike H.
Jun 11th 2007, 7:54 am
Code deleted.

They come here looking for help, and then they disappear.

I'll never understand it. Never.

Weirfire
Jun 12th 2007, 1:50 am
Code deleted.

They come here looking for help, and then they disappear.

I'll never understand it. Never.

Are you talking about me?

I live in the UK so I had to leave for home when it was time to go home. If I had stayed to wait for a reply the wife wouldn't have been too happy.

Line: 12
Char: 3
Error Code : Object doesn't support this property or method

frankcow
Jun 12th 2007, 4:19 am
Hmm, looking at it briefly, I think all of your indexof's are supposed to be camel cased, like this: indexOf

Weirfire
Jun 12th 2007, 5:07 am
Hmm, looking at it briefly, I think all of your indexof's are supposed to be camel cased, like this: indexOf

Thanks Frank. I'll give that a go.

it career
Jun 12th 2007, 5:11 am
Please find corrected code below

<html>
<head>

<script type="text/javascript">

function explodeArray(item,delimiter) {


var tempString=new String(item);
var tempString1 = new String();

if(tempString.lastIndexOf(delimiter)>0) {

tempString1 =

tempString.substr(tempString.lastIndexOf(delimiter)+1,tempString.length-tempString.lastIndexOf(delimiter)+1);


return tempString1;
}
}
function test(val) {
alert(val);
part=explodeArray(val,"/");
}


</script>
</head>
<body onload="test('a/b/c.htm')">
hell
</body>
</html>