Click to See Complete Forum and Search --> : Small looping error (1st time works)


mtdesign
10-27-2003, 02:20 PM
I have a .html page that is called X amount of times to display on a page, depending on the number of products in the db. I'm holding a db field in a variable before parsing it in script. The first time around works great, the string parses perfectly and displays. But....all other products displayed below it fail with the following error: variable cs.length is null or not an object. When I view the source code, it seems okay - the hidden field contains each new product's name. I suspect it's something with the word "this.", meaning it's only good for the first shot - right? I would appreciate any help on this - it's just a bit beyond me (but I'm gettin' there)...
Thanks!
MTDesign
p.s. the reason I put %%name%% in a hidden field was that I couldn't seem to access it in the script to parse it. ?

<input type="hidden" name="HIDECS" value='%%name%%'>
<SCRIPT LANGUAGE="JavaScript">
var cs = this.hidecs.value;
var len = cs.length;
var st = (cs.substring((len-2),len));
var cit = (cs.substring(0,(len-2)));
document.write(cit+', '+st);
</script>

mtdesign
10-27-2003, 03:04 PM
hey all - one of our javascript gurus here fixed this - thanks for looking....