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 7175655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:20:45+00:00 2026-05-28T16:20:45+00:00

Can any one help me with this.. i have an option box like this

  • 0

Can any one help me with this..

i have an option box like this

<select name="facility_info_input[facility_type_id]" id="facility_type_id">
    <option value=1 >Room</option>
    <option value=2 >Equipment</option>
</select>

i want to select one of the above options automatically according to the variable value(before user filling/updating the form the option should be already selected),
As an example i have a data variable(read from the database) and its value is 1 /2 , if its 1 can this “Room” option automatically selected,
I have been trying to use selected=”selected” attribute, but still I couldn’t figure it out how to use it,is their a any other way?

Thank you in advance..

  • 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-05-28T16:20:46+00:00Added an answer on May 28, 2026 at 4:20 pm

    Add selected="selected" to the option you want selected by default. I am assuming you are doing this server side.

    <select name="facility_info_input[facility_type_id]" id="facility_type_id">
        <option value="1" >Room</option>
        <option selected="selected" value="2" >Equipment</option>
    </select>
    

    Also, you need to enclose your attributes in quotation marks. This may be why your code wasn’t working.

    <option value="1" /> //good
    <option value=1 /> //bad
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a HTML select box like below. <select name=item_1> <option value=0>Choose one...</option>
Can Any one help me reading this XML and Looping through <MedicationDispensed> I get
Can any one please help me solve this. I am resizing some flash object/embed
How can I append a select box with same option and different name. I
I have the following html element <select id=selectStates size=5 multiple=multiple class=box> <option value=tx>Texas</option> <option
I wonder if anyone can help - I have this error showing recently when
Can anyone help me getting started with this? We have a current keygen for
Can anyone help me to do this in the right way?I mean.. like that
Can anyone offer more help on this I have the code setup on jsfiddle
Can anyone help with this... vector<unsigned int> *vVec = new vector<unsigned int>; vVec .reserve(frankReservedSpace);

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.