Forum Moderators: open
I have JS function that works in almost all browsers (IE 7, Opera 9,FF 1.5) but it doesn't work in IE 6. Could someone help me to adjust function. Here's the function:
function ProvjeriPolje(min_qty,pid) {
if (parseInt(document.getElementById('qty'+pid).value) == "0" ¦¦ parseInt(document.getElementById('qty'+pid).value) < min_qty ¦¦ document.getElementById('qty'+pid).value.length < "1")
{
alert("Error")
return false;
}
else if (document.getElementById('dimenzije'+pid).value == "#*$!")
{
alert("Dimension is not selected");
return false;
}
else {
url = "AddCart.asp?a=dodaj_u_kosaru&pid=" + pid
document.dodaj.action = url;
document.dodaj.submit();
}
}
You seem to have a semicolon missing here....
url = "AddCart.asp?a=dodaj_u_kosaru&pid=" + pid; // Missing SEMICOLON!
You could try replacing these two lines (at the end) with...
document.getDocumentById('dodaj').setAttribute('action',url);
document.getDocumentById('dodaj').submit(); And I don't think you need the ".." (quotes) around the integers...
if (parseInt(document.getElementById('qty'+pid).value) == 0 ¦¦ parseInt(document.getElementById('qty'+pid).value) < min_qty ¦¦ document.getElementById('qty'+pid).value.length < 1) Not sure why it would work in others and not IE6 though.
BEST PRACTICE
'{' should follow on same line after if
Local variables should be declared with var.
Repeated code can usually be improved.
if (parseInt(document.getElementById('qty'+pid).value) == "0" ¦¦ parseInt(document.getElementById('qty'+pid).value) < min_qty ¦¦ document.getElementById('qty'+pid).value.length < "1")
{ var v = document.getElementById('qty'+pid).value;
if (parseInt(v) == 0 ¦¦ parseInt(v) < min_qty ¦¦ v.length < 1) { Kaled