|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Defining selection using session variables on a dropdown menu
Kinda complicated (at least for me at the moment)
I am using Session Variables to store information from my forms until the input proccess page, however, my trouble is when I try and populate the drop down menus with a selection from the session. Since the session stores an ID number which points to a description in another table, it will come back with the ID number instead of the actual descriptor name. This is the code I used to use when I would just call it directly from the database (before I decided to use session variables to collect the data - I entered it step by step into the database). getselectstyle is a query which relates the styleID (number) to the style (descriptor) within the style table, and insert is the db query which returns the styleID of the actual selection. <cfif editmode><option value="#styleID#" <cfif (isDefined("listing.styleID") AND getselectstyle.styleID EQ listing.styleID)>selected="selected"</cfif>><cfoutput>#listing.style#</cfoutput></option></cfif> Since the record is not in the database, but stored in the session, is there anyway to relate the styleID stored in the session with the descriptor name (style) and how? |
|
#2
|
|||
|
|||
|
I'm not clear on the actual problem. Why can't you either store the style name in the session scope along with the styleid, or run a query that pulls the style name from the database based on the styleid?
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Quote:
I guess my problem is that Im not sure how to relay the style name along with the styleID. Since the form is relaying the ID upon the submit as the value, it can easily be picked up and stored. Im just not sure how to relate the name along with that unless I run another query based on the styleID which I didnt think would be the most effiecnt thing. The only way I can think of would be to have a query relating the ID from the form (now being stored in the session) to the name- on the process page? I guess I would then have a cfset to put the query result into the session... is that the most efficent way though? |
|
#4
|
|||
|
|||
|
Efficiency is almost never the best reason to do something, unless you really need it (ie there will be a ton of load on the server). That said, if you are only passing the ID out from the form, and then storing that ID in the session scope, then there are really only two choices: execute another query on the next page to get the information on the passed ID, or load keep a cached version of the IDs and their related data in memory (probably application scope, but session if the ID data changes from user to user) and then you can "look up" the ID in your in-memory cache of the style information.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Defining selection using session variables on a dropdown menu |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|