PDA

View Full Version : in OO javascript..how would I create or call this?


BrightNail
11-24-2002, 12:43 AM
hey all,

still trying to wrap my brains around Object orientedness in Javascript..

anyways..

lets say I have a "selectdropdown" object.....in that there are a few on a page..........and I will pass to that object parameters that will then call a certain function...

so,

lets say, that I derive something I need from the "selectedIndex" from a dropdown when the select something..

Okay,, I want to call to a function...THAT THEN (because I read the selected index, and then pass the appropriate arrays to the selectdrptdown oject...which then puts these arrays into certain fucntions that change the drop dowsn....so,,

---> onChange from a select box passes the selecteIndex to a function.

--> this function then says, for instance, ok...we just got passed index 3...so, I will now pass this to a object...

selectdropdown(priceselect3,location3,item3)

---> now this object "selectdropdown"...will take those arrays...(priceselect3, location3,item3)...and then pass them to the appropraite functions..how?

this.price=popuplateSelectprice
this.location=popuplateLocation
this.item=popuplateItem

?

am I making sense?????

I think I am not understanding the creation of the object and its values and how to use those values to throw at functions..

james

RadarBob
11-24-2002, 03:22 AM
am I making sense?????
Not much.

This is a continuation of your other thread, isn't it?

If you'd describe in *user's terms* what you're doing then maybe we can help a bit. But it sounds like you're trying to do something somewhat sophistimicated, so I suggest you first read a bit about JavaScript objects before you get any further.

A <select> is already an object. If you're trying to make several <select>s interact, then creating your own javascript objects may or may not help. But you're telling us disconnected minute details about how you want a certain solution instead of telling us what you're trying to do.

BrightNail
11-24-2002, 08:08 AM
okay,

this is the deal,,I am getting info from a database that is very complicated....and this info populates select boxes...

BUT, when you choose select boxes..the "other" boxes start to change...basically, its a very complicated 'search' feature....

when you select a dropdown, it then modifies the other select boxes to "sharpen" or make more "specific" a users search.


SO, what I was thinking is putting the 'data' into arrays..all similiar or associated data would go into a an array (there would be a few arrays)..

anyways,,,,then I was thinking of funneling these arrays..into an object that would populate the arrays...

the thing is..I've read up on Javascript objects..but I'm not understanding it...most of the examples that are shown me are dealing with the "radius and circle" etc..., and that isn't 'real world'..so I'm not grasping the usage.

basicallly, what I am thinking of is.....what or how should I go about this...just using arrays and creating functions (as normal)...or creating OBJECTS etc..

since this is fairly complicated, I don't know where to start..

any advice..

Here would be an example:

video store:

categories:
drama comedy sci-fi

movies:
various movies for each

additonal:
some movies have 'gifts' associated with them, popcorn..cola etc....can be more than one.

Now, you see how things can get complicated...cause you can select a drama...but movies from the other categories "COULD' be included and then you have to populate the additonal drop down with those items associated with all the movies that are associated with drama.

NOW, getting the data and their relationships I can handle...its HOW to go about populating the select boxes with those relationships once someone selects ANY of the selects...

Like if someone selected "popcorn" from the additional..then the movies and the categories would show up associated with the popcorn.

anyways..My dilemna is do I:

1.use tons of arrays and many functions, jumping back and forth and doing tons of checks and such.

2. using objects and somehow simplify my life...

any advice