Question : Javascript function needs a tweak

Hi, I've got this code here that works with 1 div, though when I put 2 or more divs it doesn't update the correct div.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
	var $status = true;
	function Shop($Id,status){
		if(status==true){
			alert("We are Open: "+$Id);
			document.getElementById($Id).innerHTML="Yes We Have Changed";//puts the new text in.
			$status = false;
		} else{
			alert("We are Closed: "+$Id);
			document.getElementById($Id).innerHTML = "Click Me"; //puts the new text in.
			$status = true;
		}
	}
</script>
</head>
<body>
<div id="123" onclick="Shop(123,$status)">Click Me</div>
<div id="124" onclick="Shop(124,$status)">Click Me</div>
<div id="125" onclick="Shop(125,$status)">Click Me</div>
</body>
</html>

Answer : Javascript function needs a tweak

check this :

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
	function Shop(o){
		if(o.getAttribute("value")=="true") {
			alert("We are Open: " + o.id);
			o.innerHTML="Yes We Have Changed";//puts the new text in.
			o.setAttribute("value", false);
		} else {
			alert("We are Closed: " + o.id);
			o.innerHTML = "Click Me"; //puts the new text in.
			o.setAttribute("value", true);
		}
	}
</script>
</head>
<body>
<div id="123" onclick="Shop(this)" value="true">Click Me</div>
<div id="124" onclick="Shop(this)" value="true">Click Me</div>
<div id="125" onclick="Shop(this)" value="true">Click Me</div>
<div id="126" onclick="Shop(this)" value="true">Click Me</div>
</body>
</html>
Random Solutions  
 
programming4us programming4us