Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop down box and key-value Structure

Status
Not open for further replies.

rlatham

Programmer
Aug 23, 2000
51
0
0
US
Hello,
I would like my code to populate a key-value structure according to the selection from a Drop down box called "ThisActivity" (Chess Club, Soccer, Golf), the keys of the structure (example: Ts-YM, Ts-YL) are contained in a table, the structure name is "Items", and the user should be able to change the values in the structure from 0 (zero) to any other number.

Thanks in advance for your help.

=)
 
I think you need to explain your problem a bit better, and possibly post some code. I read your post several times, and I cannot figure out what the Chess Club, Soccer, Golf, have to do with the "structure" (which could also use some more explanation - what is it? an object you've made?). You say you want the structure populated according to the selection from the drop-down box, but I do the drop-down selections correspond to the keys, or to the values?

I'll try to give you some help if you can help me understand.

T
 
T,
Thanks a lot for your reply.

I do not have any code for that yet, so perhaps I shouldn't call it "my code". Sorry.

Hope this is explained better.

I am using Coldfusion to create a form. The user is ordering T-shirts for the team.

What I wish to accomplish in part of this form is the following:

The user will select an activity (examples: chess club, soccer, golf). The change in the drop down box should trigger something that will create/populate a key-value structure that I wish to call "Items" which contains a list of items, these items have the keys: Ts-YM, Ts-YL (these keys come from the table Products) and the values are the quantity that the user will enter. The default number will be 0. The values should be represented in a text box.

The key-value structure will allow me to use the keys as another piece of data, that I can manipulate later.
The key-value structure is like an array that has alphanumeric indexes (keys) instead of just numeric.

The activity only tells me which items I should display.
The Products table has several items that are sold just for that activity, let's say just t-shirts are sold for soccer, and just hats are sold for golf and just Sweat shirt are sold for the chess club. Hence, according to the activity selected the structure should display the items that belong to that particular activity.

If this is too complicated and you know an easier way to do this, please let me know.

Mainly, I wish to know how to capture the value of the activity selected in the drop down box and be able to assign that value to a ColdFusion variable to use it in the same page without having to reload it.

Thanks again!

R.Latham



 
Well,

Good explanation, at least I now understand your problem.

I don't use ColdFusion (hiss), but I GUARANTEE you that you can do these things with a minimum of JavaScript. All of your data (keys and values -- for which I usually use a hashmap or similar data structure) should be in objects at the server level. Then you can dynamically generate javascript to do the job fairly easily. I'd head on over the to tek-tips CF forum and see what you can find.

For the javascript part, I think one of the easiest ways to do this would be to generate the proper form fields for ALL of the activities, stick them in layers, and turn the layers on and off with document.layername.visible = false/true in an onselect event out of the drop-down menu.

Good luck with this one, if you get further along and need some help making the javascript stick (using the DOM can be a PITA sometimes), stick it in this thread - I have it emailing me.

T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top