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> Code (markup):
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
Hmm, looking at it briefly, I think all of your indexof's are supposed to be camel cased, like this: indexOf
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> Code (markup):