Sorry I can't see the solution in there.
I am very well aware that what = alert( '' ); would evaluate
immediately, if you look at my first sample you will see that I have
it within quotes. I think what I want to do just can't be done, and I
have to write the function outside the object.
On 2/22/06, Steve Onnis <[EMAIL PROTECTED]> wrote:
>
> 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.
>
>
>
>
>
--
Taco Fleur - http://www.pacificfox.com.au
Web Design, Web development, Graphic Design and Complete Internet Solutions
an industry leader with commercial IT experience since 1994 …
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cfaussie
-~----------~----~----~----~------~----~------~--~---