S
suzanne.boyle
This has been driving me round the bend for hours and I'm not sure
what I should be googleing for to look for a solution so please help!
When you click a div I want to show another div, then when you either
click on either the first div or the newly shown one it hides it
again. I think I'm on the right track, this is my code...
function openDiv(ddl, options) {
this.ddl_obj = document.getElementById(ddl);
this.options_obj = document.getElementById(options);
this.ddl_obj.onclick = dropdownMenu.prototype.click;
this.options_obj.onclick = dropdownMenu.prototype.click;
}
openDiv.prototype.click = function() {
alert(this);
if ( this.options_obj.style.display == 'none' )
this.options_obj.style.display = 'block';
else
this.options_obj.style.display = 'none';
return true;
};
and at the bottom of the page...
obj = new openDiv('div1','div2');
The problem is when the event is being handled, this in the handler
points to the html object that fired it. I want it to point to the
openDiv object. Am I anywhere near to a solution. As you can
probably tell, javascript is not my best subject.
what I should be googleing for to look for a solution so please help!
When you click a div I want to show another div, then when you either
click on either the first div or the newly shown one it hides it
again. I think I'm on the right track, this is my code...
function openDiv(ddl, options) {
this.ddl_obj = document.getElementById(ddl);
this.options_obj = document.getElementById(options);
this.ddl_obj.onclick = dropdownMenu.prototype.click;
this.options_obj.onclick = dropdownMenu.prototype.click;
}
openDiv.prototype.click = function() {
alert(this);
if ( this.options_obj.style.display == 'none' )
this.options_obj.style.display = 'block';
else
this.options_obj.style.display = 'none';
return true;
};
and at the bottom of the page...
obj = new openDiv('div1','div2');
The problem is when the event is being handled, this in the handler
points to the html object that fired it. I want it to point to the
openDiv object. Am I anywhere near to a solution. As you can
probably tell, javascript is not my best subject.