you cant do it like that taco

if you have
myListItem.onclick = "alert('hello');";

you will see the list item gets populated with the alert

if you have
myListItem.onclick = "alert(this);";

it uses the object, in your case the <li> element as what "this" is, not the
prototype object

you cant have
myListItem.onclick = alert(this);

because the alrt will run when the function is run, just like whats
happening with your function.

with your prototype, you cant just reference "this" in your function as
though it was still part of the prototype.

your onclick needs to have a reference to the prototype so it knows which
instance it needs to work with

///////////////////////////////////
<script>

        function tab() {
                this.instance = arguments[0];
                this.tabs = new Object();
                }

        tab.prototype.addTab = function (label, link) {
                this.tabs[label] = new Object();
                this.tabs[label].label = label;
                this.tabs[label].link = link;

                }

        tab.prototype.getName = function () {
                alert(this.instance);
                }

        tab.prototype.writeTabs = function () {
                var htmlStr = "<table><tr>";
                for (p in this.tabs) {
                        htmlStr = htmlStr + "<td><a href=\"" + 
this.tabs[p].link + "\"
onclick=\"" + this.instance + ".getName()\">" + this.tabs[p].label +
"</a></td>";
                        }
                htmlStr = htmlStr + "</tr></table>";
                return htmlStr;
                }

        myTabs = new tab("myTabs");
        myTabs.addTab("tab 1", "index.cfm");
        myTabs.addTab("tab 2", "index.cfm");
        myTabs.addTab("tab 3", "index.cfm");
        myTabs.addTab("tab 4", "index.cfm");

        document.write(myTabs.writeTabs());
</script>
////////////////////////////////////////

just a quick example

you need to let the onclick know what its suposed to be doing.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to cfaussie@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cfaussie
-~----------~----~----~----~------~----~------~--~---

Reply via email to