[thelist] Javascript help please

jeff jeff at members.evolt.org
Thu Jan 25 05:01:31 CST 2001


duncan,

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Duncan O'Neill
:
: I'm coding a client-side Javascript
: application(?) which has gotten away
: on me.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

yeah, they have a way of doing that don't they?

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: It's designed to hold a SMALL database
: of employee names and info using cookies.
: Yeah, I know there's probably a better way,
: but I don't know any other language to code
: it in.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

i'm guessing that this data is only being viewed/edited/etc by one
individual (presumably the one with the cookie and the data).

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: My problem is in passing the string variable
: from the prompt to tell the script WHICH
: employee's information to change, so that I
: can eventually pass the info to the promote
: function like so;
:
: charlie.promote(new_title, salary_increase);
:
: How do I use eval() or any other method to
: pass the string from the prompt, AND change
: it into a variable for the promote function?
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

it'd help to see more of your code, perhaps even a working example.
however, i'd wager a guess that if i say the phrase "associative array" that
might help you out some.  don't forget that practically everything in
javascript that uses the dot notation
(obj.other_obj.another_obj.still_another_obj) allows you the ability get at
that same data via an associative array.  take a form element, for example,
referred to by form name and element name to get it's value:

document.form1.first_name.value;

that could just as easily have been:

document.forms['form1'].elements['first_name'].value;

you starting to see where i'm going with this?

i'm guessing that ol' charlie up there is part of a larger collection of
objects, Employee perhaps?  well, if that's the case then you just might be
able to refer to him like this:

Employee['charlie'].promote(new_title, salary_increase);

again, without seeing your code, this is just my arse whistling dixie.

good luck,

.jeff

name://jeff.howden
game://web.development
http://www.evolt.org/
mailto:jeff at members.evolt.org





More information about the thelist mailing list