Question : is there anyway of changing the onclick message?

Hi, I've got this function below

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.
}else{
alert("We are Closed: "+$Id);
document.getElementById($id).innerHTML=????;//grabs the default text of 'Click Me' within the div
}


}

<div id="123" onclick="Shop(123,$status)">Click Me</div>


so when you click on it, it changes, and when you click on it again it changes back to default.

Answer : is there anyway of changing the onclick message?

$ is not generaly used with pure javascript variable. Using << id >> is fine.
$ is generaly used for framework object

Else check this (I let the $ to follow you) :

In the following we've $status and status.
$status is a global var.
status is a parameter.

$status and status is not the same variable

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
<!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>
</body>
</html>
Random Solutions  
 
programming4us programming4us