Classes

This is a discussion on "Classes" within the JavaScript Forum section. This forum, and the thread "Classes are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Mar 5th, 2006, 19:28
Up'n'Coming Member
Join Date: Jan 2006
Location: East Sussex
Age: 26
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Question Classes

Hi everyone,
I have created a class but am stuck on a particular bit, i have shown an example of the class and then explained how it works...i hope!
function update()
{

this.action;

update.prototype.setAction = function(command)
{
this.action = command;
}

update.prototype.action = function()
{
this.action;
}

}
so the idea is that a user can set the action and then use it at a later date, ie update.setAction(alert("It works!")) then when ever update.action() is called an alert box pops up saying It Works!
Im sure it cant be that hard but cant seem to get it to work, thanks in advance.
Reply With Quote

  #2 (permalink)  
Old Mar 8th, 2006, 08:31
Up'n'Coming Member
Join Date: Jan 2006
Location: East Sussex
Age: 26
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Classes

For anyone thats interested the code should be as follows;

function update()
{

this.action;

update.prototype.setAction = function(command) //command passed as string
{
this.action = command;
}

update.prototype.action = function()
{
eval(this.action);
}
}


just use the eval() function! So simple really! Hope this helps someone in future.

Gee
Reply With Quote
Reply

Tags
classes

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
variable classes CloudedVision PHP Forum 4 Feb 14th, 2008 03:07
Using Classes tox0tes Flash & Multimedia Forum 1 Nov 9th, 2007 14:12
Classes in PHP pas2gether PHP Forum 11 Oct 13th, 2007 17:24
Classes pa007 PHP Forum 6 Jul 12th, 2007 15:22
Styles in classes? timmytots Web Page Design 4 Dec 2nd, 2005 01:20


All times are GMT. The time now is 00:05.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43