S
Stever1975
I'm working on something similiar to a shopping cart item page. There
is a table of items. Each item has an image, a textbox for the qty
and an image for the add button.
When the add image is clicked it adds the item to the cart array and
sums it if the item already exists in the cart.
This code works perfectly fine in Internet explorer and firefox, heck
I even tested it in chrome and it works.
So everything works fine in all browsers when it's just the table of
items and the javascript code. But when this code is Included into
another page ( the page with menu, footer, and header). It errors out
in firefox with the following error (works fine in other browsers):
txt9360303S is not defined
[Break on this error] Cart[Item]=parseInt(Cart[Item]==undefine...]) +
parseInt(eval(textbox + '.value'));
(the '...' is because the debugger could not display all the code)
Both pages are in the same directory.
I'm figuring that by including it in another page I'm some how messing
up the DOM. But I can't figure how. So I guess what I'm wondering is
there a particular firefox gotcha that would cause this.
Below is the javascript function I'm using and the html for one of the
items.
<table><tr><td><input type=text size=2 value=1 name='txt9360303S'
id='txt9360303S'></td><td><div id='additem' name='additem'
onClick=AddItem('936030/3S')><img src='btnAdd1.jpg' border=0></div></
td></tr></table>
The Javascript function:
var AddItem=function(Item){
textbox='txt' + Item.replace('/','')
Cart[Item]=parseInt(Cart[Item]==undefined ? 0 : Cart[Item]) +
parseInt(eval(textbox + '.value'));
//DisplayItemQty(Item);
DisplayAllQty(Cart);
//alert(Display(Cart));
}
is a table of items. Each item has an image, a textbox for the qty
and an image for the add button.
When the add image is clicked it adds the item to the cart array and
sums it if the item already exists in the cart.
This code works perfectly fine in Internet explorer and firefox, heck
I even tested it in chrome and it works.
So everything works fine in all browsers when it's just the table of
items and the javascript code. But when this code is Included into
another page ( the page with menu, footer, and header). It errors out
in firefox with the following error (works fine in other browsers):
txt9360303S is not defined
[Break on this error] Cart[Item]=parseInt(Cart[Item]==undefine...]) +
parseInt(eval(textbox + '.value'));
(the '...' is because the debugger could not display all the code)
Both pages are in the same directory.
I'm figuring that by including it in another page I'm some how messing
up the DOM. But I can't figure how. So I guess what I'm wondering is
there a particular firefox gotcha that would cause this.
Below is the javascript function I'm using and the html for one of the
items.
<table><tr><td><input type=text size=2 value=1 name='txt9360303S'
id='txt9360303S'></td><td><div id='additem' name='additem'
onClick=AddItem('936030/3S')><img src='btnAdd1.jpg' border=0></div></
td></tr></table>
The Javascript function:
var AddItem=function(Item){
textbox='txt' + Item.replace('/','')
Cart[Item]=parseInt(Cart[Item]==undefined ? 0 : Cart[Item]) +
parseInt(eval(textbox + '.value'));
//DisplayItemQty(Item);
DisplayAllQty(Cart);
//alert(Display(Cart));
}