Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7745335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:59:21+00:00 2026-06-01T09:59:21+00:00

I am trying to create a drop down list that incorporates database data and

  • 0

I am trying to create a drop down list that incorporates database data and a custom loop at the same time. I need the list to show as “selected” the data coming from the database but also to allow the user to change it if needed with other data on the list.

More specifically, this is what I have so far:

<select name="openHours#CountVar#">
    <cfloop from="0" to="23" index="OpenHours">  
        <option value="#OpenHours#"><cfif doctorHours.openTime neq ''>#TimeFormat(doctorHours.openTime)#<cfelse>#OpenHours#</cfif></option>
    </cfloop>
</select>

The problem with this code is when a value is actually pulled from the database the rest of the value options are disappearing because #OpenHours# is isolated and I can have only one or the other. Also the value should be dynamic as well to get in the correct value in case of an update.

Can I incorporate this part

<cfif doctorHours.openTime neq ''>
    #TimeFormat(doctorHours.openTime)#
 <cfelse>
     #OpenHours#
 </cfif>

.. in a “selected” option somehow in order to have the correct value showing on my drop down list and also be able to press on the list and choose another option to update my time table if needed?

Adding more info on what I need:

I have a db table with 3 columns in it. An ID, openHours, and closeHours.
What I am trying to achieve is:
Create a drop down list that has hours from 0 to 23. Then check my db, if the openHours, and closeHours are not empty, get those values and have them as the pre-selected values on the drop down list.
If my doctor opens at 9am and close at 6pm the the two drop down lists will have selected 09 and 18 and also allow me to choose another option if I want to update them.
So i guess I need to check my db table and if my data match with any of the data in the drop down list, make that selection as the selected on.

hope that makes more sense now. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:59:23+00:00Added an answer on June 1, 2026 at 9:59 am
    <select name="openHours#CountVar#">
        <cfloop from="0" to="23" index="OpenHours">  
            <option value="#OpenHours#"<cfif TimeFormat(doctorHours.openTime,'H') EQ    OpenHours> selected="selected"</cfif>>#OpenHours#</option>
        </cfloop>
    </select>
    

    This should give you what you’re looking for. It loops through the list 0 to 23 and displays each one. If the value being displayed matchs doctorHours.openTime then it will show as selected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create an extension that renders a read-only drop down list.
i m trying to create a drop down list that takes values on the
I am trying to create a drop down list using asp.net mvc. Model: public
I'm trying to create a drop down list in an ASP.NET MVC3 view based
I'm trying to create a custom drop down and using the code below it
I am trying to create a drop down list. I have it working but
I'm trying to create a default value for my dynamic drop down list. After
Lets say that I have a drop down list that I want to create
I'm trying to create a dynamic list that will show item of my city
I'm trying to create a drop down button and its almost working except one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.