Forum Moderators: coopster

Message Too Old, No Replies

setting checked value with a dynamic dropdown

is there an 'easier' way?

         

generic

9:06 pm on Jan 19, 2006 (gmt 0)

10+ Year Member



Hi,

This may be rudimentary but I'm just trying to get my head around this without having to write a billion lines of extraneous code.

I have a dropdown selection list, populated from a mySQL database, containing times in a HH:MM:SS format. The times are 30 minutes interval spanning an entire day, as in 01:00:00, 01:30:00, 02:00:00 all the way to 24:00. I have it entering fine into the database, but when I want to edit this time, I'd like to have the value in the database be marked as the CHECKED value on the dropdown so I don't have to manually re-enter the time for every edit.

Is there a better way to do this or am I doomed to verify each entry individually?

Hope this all makes sense.

gen

coopster

1:50 am on Jan 20, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



A very common practice is to pre-select a value based on an existing list and an *already selected* value. You loop through the entries and compare to your *selected* value and if it is a match you just modify that option in your select list.

Here is a small example of how you might accomplish the task:
[webmasterworld.com...]

generic

2:16 am on Jan 20, 2006 (gmt 0)

10+ Year Member



Wow, that looks fun. Actually, I can see that it must be beyond my meager skills (or maybe I'm just having a moment). I'll have to take some time and look into a bit more thoroughly. Thanks for the heads-up!

coopster

2:18 am on Jan 20, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It's not too terribly difficult. Give it your best shot, if you get stuck -- well, that's why this forum is here! There are a lot of talented folks hanging out in here that are ready to give you a hand.

generic

2:21 am on Jan 20, 2006 (gmt 0)

10+ Year Member



True that.. alright, I'll consider that a challenge lol Thanks :)