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.
|
|
|
|
|
![]() |
||
Classes
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
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. |
|
|
|
|||
|
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 |
![]() |
| Tags |
| classes |
| Thread Tools | |
|
|
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 |