Jump to content

Firefox Javascript Does Not Work


alias92

Recommended Posts

this code with red color does not work on firefox. it works on ie and google chromewhat is the problem please help me...<tr><input type="hidden" name="product_id_<% = counter %>" id="product_id_<% = counter %>" value="<% = rs("product_id") %>"> <td class="a-center" width="20"><a class="a-center" href="?OPERATION=delete&basket_item_id=<%=rs("basket_item_id")%>" title="<%=removes%>"><img src="http://forum.ceviz.net/images/delete.gif" alt="<%=removes%>" /></a></td> <td><a href="product.asp?product_id=<%=rs("product_id")%>" class="product-image" title="<%=rs("title" & language_constant)%>"><img src="<%=rs("img3")%>" height="100" alt="<%=rs("title" & language_constant)%>" /></a></td> <td width="400"> <h3 class="product-name"><a href="product.asp?product_id=<%=rs("product_id")%>"><%=rs("title" & language_constant)%></a></h3> </td> <td class="a-center" width="20"> <div class="cart-price"><span class="price"><%=rs("price")%> TL</span></div><input type="hidden" name="price_each_<% = counter %>" id="price_each_<% = counter %>" value="<%=rs("price")%>"> </td> <td class="a-center" width="20"> <input name="product_count_<% = counter %>" id="product_count_<% = counter %>" value="<%=rs("quantity")%>" size="4" class="input-text qty" maxlength="8" /> </td> <td width="120"> <div class="cart-price"><span class="price"><%= (rs("price") * rs("quantity"))%> TL</span></div> </td> <td class="a-center"> <a href="java script:updateProduct('<% = rs("basket_item_id") %>','<% = counter %>')">update<img src="http://forum.ceviz.net/images/update.gif" border="0"></a> </td></tr><script language="Javascript"> function checkInput(counter, quantity){ if (isNaN(eval('document.all.product_count_' + counter).value) || eval('document.all.product_count_' + counter).value.length == 0){ eval('document.all.product_count_' + counter).value = quantity; } } function updateProduct(basket_item_id, counter){ var session_id = ; var quantity = eval('document.all.product_count_' + counter).value; var width = 300; var height = 150; var y =(screen.availHeight-height)/2; var x =(screen.availWidth-width)/2; window.basketWin = location.href='basket.asp?OPERATION=update&session_id='+session_id+'&basket_item_id='+basket_item_id+'&quantity='+quantity,'basket'; window.basketWin.focus(); } function deleteProduct(basket_item_id){ var width = 300; var height = 150; var y =(screen.availHeight-height)/2; var x =(screen.availWidth-width)/2; window.basketWin = window.open('basket.asp?OPERATION=delete&basket_item_id='+basket_item_id,'basket','toolbar=0, scrollbars=2 ,width='+width+',height='+height+',top=' + y + ',left='+ x); window.basketWin.focus(); } </script>

Link to comment
Share on other sites

document.all is a very old property that Microsoft invented for IE before the adoption of the id property by the W3 standards people. Until now, I thought only IE continued to support it, and I'm surprised to learn that Chrome does. It is non-standard and I don't think it will ever be supported by Mozilla, Webkit, etc. (They would have added it years ago in that case.)If your inputs are part of a form, you can get a reference using document.formname.elementname . But this will not work if the inputs are not part of a form.Using an id property with document.getElementById('myid') is a W3 standard and supported by everyone.

Link to comment
Share on other sites

FWIW, that code overuses the eval() method also. It too was common in the early days, as a work-around for properties that JavaScript and W3 had not invented yet. id properties other DOM properties/methods easily replace it and potentially make for faster code.

Link to comment
Share on other sites

This is not a part of a form.i dont know using document.getElementById property. how can i change my updateProduct function.in my code <tr> to </tr> ; there is a loop for each product , quantity and price.i want to update quantity then after updating quantity, it gets total priceplease help me using function

Link to comment
Share on other sites

Because you have also given an id property to your inputs, I think you can replace this eval('document.all.product_count_' + counter).valuewith this document.getElementById('document.all.product_count_' + counter).valueYou will need to make that change everywhere you use document.all.NOW. This line looks incorrect:window.basketWin = location.href='basket.asp? . . .Should it be:window.basketWin.location.href='basket.asp? . . .This part looks wrong too:. . . '&quantity='+quantity,'basket';That comma doesn't really do anything, and I don't think the word "basket" will be placed anywhere.I have to tell you. This is very old code. Some of your HTML is incorrect, and most of it uses bad-practice. If you are trying to adapt someone else's page to your situation, you might be wise to improve your knowledge and start over.

Link to comment
Share on other sites

i choose my problem like thisfunction updateProduct(operation, basket_item_id, counter){ var session_id = <% = Session_id %>; var quantityz = document.getElementById('product_count_' + counter); var quantity = quantityz.value; var width = 300; var height = 150; var y =(screen.availHeight-height)/2; var x =(screen.availWidth-width)/2; window.basketWin = location.href='basket.asp?OPERATION=update&session_id='+session_id+'&basket_item_id='+basket_item_id+'&quantity='+quantity,'basket'; window.basketWin.focus(); }

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...