M
Martin
I am writing a javascript object and once complete i will create an
instance of the object to use in my webpage.
Within the object constructor i create a form with a select list in
it, the form is contained in a DIV element.
I want the select list onChange event to call a method of my object.
So the constructor is:
function PanoramaViewer()
{
// code snipped for clarity
// DIV containing form and select list created
// the form HTML is:
// <form name="indexForm"><select name="indexList"
onChange="call_myEvent"></select><br>Auto-hide index: <input
type="checkbox" name="autoHideIndex" checked disabled></form>
this.myEvent=function() { // some script here; };
}
And i create an instance of my object:
var myViewer=new PanoramaViewer();
As you can see i want the select box onChange event to call the
myEvent function.
How can i do this?
onChange="myEvent()" fails as myEvent() is not found in the scope of
the event call.
onChange="myViewer.myEvent()" works as it directly references the
method of the object instance but obviously i don't want to have the
name of an object instance hardcoded into the constructor.
(It works as a hack but isn't really valid).
I've spent a few days searching for ways to have the onChange event
call the instances' myEvent method but found nothing that helps.
Any ideas?
Thanks a lot.
Martin.
PS I can post more detail if needed.
instance of the object to use in my webpage.
Within the object constructor i create a form with a select list in
it, the form is contained in a DIV element.
I want the select list onChange event to call a method of my object.
So the constructor is:
function PanoramaViewer()
{
// code snipped for clarity
// DIV containing form and select list created
// the form HTML is:
// <form name="indexForm"><select name="indexList"
onChange="call_myEvent"></select><br>Auto-hide index: <input
type="checkbox" name="autoHideIndex" checked disabled></form>
this.myEvent=function() { // some script here; };
}
And i create an instance of my object:
var myViewer=new PanoramaViewer();
As you can see i want the select box onChange event to call the
myEvent function.
How can i do this?
onChange="myEvent()" fails as myEvent() is not found in the scope of
the event call.
onChange="myViewer.myEvent()" works as it directly references the
method of the object instance but obviously i don't want to have the
name of an object instance hardcoded into the constructor.
(It works as a hack but isn't really valid).
I've spent a few days searching for ways to have the onChange event
call the instances' myEvent method but found nothing that helps.
Any ideas?
Thanks a lot.
Martin.
PS I can post more detail if needed.