I'm in way over my head on this one and this 62 year old grandma is starting to sink.
What was needed was a centralized javascript routine that would build HTML code to create a table cell containing a form and button that would be configured on a only a few changing variables.

Through a lot of searching and trial and error I came up with this:
The calling code from HTML looked like this:

This code works in both IE and Firefox.
Originally I used 'form' instead of 'formref' and would get an error that form did not exist in Netscape.
After changing 'form' to 'formref' the error is gone, but no button appears either.

I've searched the net from end to end I everything I try is either ineffectual or breaks the code.

Hopefully someone that actually knows what they are doing can help me.

Thanks
Jenny
PS: Preferably the fix is in the javascript routine and not the calling routine which would involve changing several hundred pages of code.

nikkiH

02-27-2007, 08:42 PM

While the code really needs a complete overhaul to be DOM compliant, for now, try changing the image submit to a real submit button and removing that style.
Verify that a normal button works. If so, the problem is either in your relative image path or the inline style.

glenngv

02-27-2007, 09:12 PM

This is the cause of the error:

var click = 'onclick=\'addToCart(\"'+item_id+'\",\"'+name+'\",this.form);\'';
document.write('</select><input type="image" src="images/AddToCart.gif" alt="Add to Cart" value="Add to Cart" '+click+' style="margin-top:0; margin-bottom:0; float:center; height:32"></form></td>');
return;
The this.form is attached to an input type=image. Although this is an input tag, this.form is not valid for input type=image. If you use a normal submit button, it will work. But if you really want to have an image submit button you need to change this.form to the full reference of the form and name the form.

However I am still getting the same error in the netscape javascript log and no button on the screen.
--------------------------------------------
Error: missing name after . operator
Source File: http://jennyvision.com/cart2.js
Line: 47, Column: 20
Source Code:
var tmp = formref.package.options[formref.package.selectedIndex].text;
--------------------------------------------

PS: This test was done on one of the single title screen page pages. On the list pages this routines is called once for every title. Will having the same name be an issue, and if it is is there away around it? (I begin to perceive one using random numbers but how to be certain it is not repeated?)

Thanks again
Jenny

One last PS: How do I create those nice boxes for the code in these messages? I don't see a button for them.

Jenny1945

02-27-2007, 11:35 PM

While the code really needs a complete overhaul to be DOM compliant, for now, try changing the image submit to a real submit button and removing that style.
Verify that a normal button works. If so, the problem is either in your relative image path or the inline style.
Without the two style lines the form expands to about double the height needed, pushing out the cell and looks horrible. It still does this in Firefox to some degree even with the style, but I have found no way to gain reliable control over the form and cell.

This style tip I found has been as close as I have been able to get.

Jenny

glenngv

02-28-2007, 02:59 AM

If the function will be called many times, then you must name the form differently. Just pass a unique or sequential number to the function.

I ran into the dash problem as I started work on the change. Also had a problem that some item numbers are simply a three digit number. So I wrote a snippet that used just the 3 digit number and appended "F" to the beginning.

But the big news is, I have found the problem.
'Package' turns out to be a reserved word as far as Netscape is concerned. I changed it to 'Packaging' and all works well now.

Thank you for all your help, the various changes have made the code fundamentally better, helped me to understand more of what was going on, and in doing so allowed me to focus on the area with the actual problem (oddly, exactly where it was saying the problem was - who would have thought? :) )