I thought I had a solid plan to do this but somehow or the other it is not working…
But what I did, I have a variable on a web page some where (this is an asp.net MVC application). Based on what this variable is, I will change the style of one of two div’s two visible and then remove the style attribute (I have both of those two divs with a style element set to “display:none”). Now the first one works but the second one does not? I keep getting a javascript error that tells me that an object is required (I would give you the exact error but my web server isn’t working for some reason).
Activate/Deactivate Patient
<div id="deactivateNO" style="display:none"><%=Html.RadioButton("deactivate", "N", false)%>Deactivate</div>
<div id="deactivateYES" style="display:none"><%=Html.RadioButton("deactivate", "A", false)%>Activate</div>
Those are the div’s that I have described with the radio buttons inside. What follows are the javascript functions I call to make one of those divs appear or disapear…
function ShowMessage()
{
var timer = setTimeout("Show()", 1200000);
//debugger;
var active = "<%= Active %>";
if (active == "A")
HideActivate();
if (active == "N")
HideDeactivate();
}
function HideActivate()
{
//debugger;
var obj = document.getElementById("deactivateNO");
obj.style.visibility = 'visible';
obj.removeAttribute('style');
}
function HideDeactivate() {
//debugger;
var obj = document.getElementById("deactivateYes");
obj.style.visibility = 'visible';
obj.removeAttribute('style');
}
The first function calls either of the final two functions. The first function seems to work well. The second function seems to be giving me trouble… When I have my debugger going, it always bugs out on the obj.style.visibility = ‘visible’; When I look at the obj object it is always null? Which tells me that it can’t find the deactivateYes Id? I have looked at the source and it appears as though it is there. I will double check, but I am pretty sure it is.
is deactivateYes and deactivateYES the same…
this is why it will fail to find the element, the ids dont match
have to really careful about case 😉