Javascript Mac OS/ FF Browser Uncompability

I

infiniti

Hi,
I am coming across a problem with the javascript code on this
site (http://www.acnecomplex.net/buy.aspx). If you click on the yellow
'Proceed to Checkout' button on this page on a Mac OS or a Firefox
browser, it does not do anything. It works fine with IE on Windows.
I am calling a Javascript function funcKit when someone clicks on the
button.

HTML code for the button:
<a href="javascript:funcKit();" title="PROCEED TO CHECKOUT
&raquo;"><img src="images-acne-complex/buy-now/buy-now-fw-27.gif"
width="230" height="45" border="0" alt="Proceed to checkout"></a>

Javascript Function:
function funcKit()
{

var intResult;
var productArray = new Array(51,53,55,56,52,54,57,58);

intResult=0;
if (window.document.getElementById("checkbox1").checked)
{
intResult=intResult + 1;
}
if (window.document.getElementById("checkbox2").checked)
{
intResult=intResult + 2;
}

if (window.document.getElementById("checkbox3").checked)
{
intResult=intResult + 4;
}

window.location.href="detail.aspx?id=" + productArray[intResult];


}



Can anyone please tell me why it is not working and what is the
solution for this problem.

Any help is greatly appreciated.

Thanks,

Amber
 
R

RobG

infiniti said:
Hi,
I am coming across a problem with the javascript code on this
site (http://www.acnecomplex.net/buy.aspx). If you click on the yellow
'Proceed to Checkout' button on this page on a Mac OS or a Firefox
browser, it does not do anything.

It does do something. If you look in the JavaScript console, you'll see
the error message:

"Error: window.document.getElementById("checkbox1") has no properties
Source File: http://www.acnecomplex.net/ac-buy-now.js
Line: 8"

That is because you have an input with a *name* of checkbox1. There is
no need for getElementById at all, use the forms collection instead for
better cross-browser support. Give your form a name, then you can go
through the checkboxes with something like:

var f = document.forms['formName'];
var i = 1;
var intResult = 0;
var cb;
var cbFactors = {1:1, 2:2, 3:4};

while ( (cb = f.elements['checkbox'+i]) ){
if (cb.checked) {
intResult += cbFactors;
}
++i;
}


And life should be sweet again. Untested, but it should give you an
idea of what to do.

[..]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top