Forum Moderators: open

Message Too Old, No Replies

Checkbox problem just in SAFARI

         

smagdy

11:00 pm on Dec 2, 2007 (gmt 0)

10+ Year Member



Hello!

This code works in IE6 & 7 & FF but not Safari in windows.

var prod_id = "C1"

if (document.getElementById(prod_id).checked)
alert("1")
else
alert("0")

There is a checkbox, and another link, when i click the link it should alert 0 if the checkbox is not checked and 1 if it is checked.

It works fine in IE6 & 7 & FF but in Safari windows, it always alerts 0.

So what is the way to let it work in Safari too?

Thanks in advance

rocknbil

11:17 pm on Dec 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you try this? It should still work, maybe it's the lack of brackets or the value:

if (document.getElementById(prod_id).checked == true) {
alert("1");
}
else {alert("0"); }

smagdy

11:57 pm on Dec 2, 2007 (gmt 0)

10+ Year Member



Just tried it now, but same result :(

smagdy

2:26 pm on Dec 3, 2007 (gmt 0)

10+ Year Member



Thanks, i don't need a solution anymore as i reached a different approach.

Thanks