First, please enclose your code in the code pseudocode tags (in square brackets), as I have done below. Otherwise, your code turns into zxnrbl through auto formatting.
<div id="Panel1" style="WIDTH: 64px; HEIGHT: 48px; BACKGROUND-COLOR: yellowgreen" onclick="checkedChanged(this,Checkbox1)" runat="server">
The above tag can't possibly work, for the following reasons:
- The div tag doesn't know how to use an onclick attribute, because a div box isn't a clickable object.
- The value "Checkbox1" is not defined in the scope the div tag can see. It should be in single quotes.
- The runat attribute must be in the html tag itself, not in the individual tags for web page elements.
I suggest totally removing the onclick and runat from this tag.
Now for the next tag:
<img id="imgcolor" name="img" style="WIDTH: 32px;
HEIGHT: 31px" height="31"
src="file:///\\system107\HIS\Images\seat2.jpg"
width="32" align="middle" runat="server" />
There are numerous reasons why this tag doesn't work:
- Styles are always lowercase. Change the case in your styles attribute, or to make it better, put them in a style in the stylesheet.
- the runat tag is not defined for individual tags, but only for the html tag. Remove it and put it in the html tag.
Now for the next tag:
<input type="checkbox"
onclick="javascript:var temp=this;alert(temp);"
id="Checkbox1" name="Checkbox1" />
It doesn't do anything except tell you where you are! As soon as you leave the Javascript part of the onclick in this tag, the value of the variable declared in it can be forgotten. It is not guaranteed to carry over to other JavaScript calls (some browsers do, some don't). Only global variables and the contents of input elements are retained.
This is really where you need to call your checkedChanged function, instead of in the div. Then, in the Javascript, refer to the background color of the div by using its complete variable description, including its id. You can pass it as a parameter in single quotes.
The last tags:
<label id="Label1" runat="server"></label>
</div>
The runat attribute is not defined here either.i want to pass temp value to the onclick="checkedChanged(this,temp)"
how to pass the checlbox this value or temp value in that function..
please reply.......
The problem is that you are calling the function from the wrong tag. Call it from the input tag.