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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:38:32+00:00 2026-05-27T10:38:32+00:00

I am adding a feature to edit the ads a user puts. For that

  • 0

I am adding a feature to edit the ads a user puts. For that I want to make the value selected which is selected by the user when he entered the values . How can I implement this?

<div class="nm">
  Category
</div>
<div class="fl">
  <select name="category" id = "ad_category" onchange="cangeSubCat(this.value)" >
    <option value="">---Select Category---</option>
    <option value="real_estate">Real Estate</option>
    <option value="hotels_resturants">Hotels and Resturants</option>
    <option value="car">Car Rental</option> 
  </select>
</div>
  • 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-27T10:38:32+00:00Added an answer on May 27, 2026 at 10:38 am

    Add the selected HTML <option> attribute, in XHTML it is selected="selected".

    <option value="value" selected>title</option>
                          ^^^^^^^^
    

    Documentation: http://www.w3.org/TR/html4/interact/forms.html#h-17.6.1

    I mean how will I know which one should be selected..it will be different for different users . I wnt it to be selected which user selects during adding the ad

    That depends on your code. You can do this with an array with all value/title pairs (value => title) and the value which is selected. Then when key (value) equals the selected one, the attribute is added in output. As it’s an array it’s easy to iterate over it.

    $otpions = array(
        'a' => 'A',
        'b' => 'B',
    );
    $selected = 'b';
    
    echo '<select>';
    foreach ($options as $value => $title)
    {
        printf('<option value="%s" %s>%s</option>', 
               $value, $selected == $value ? 'selected' : '', $title);
    }
    echo '</select>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm adding a new feature to my user module for my CMS and I've
How can I prevent users from adding new tags which don't already exist in
I'm working on a feature that will allow a user to click onto a
I'm adding a password reset feature to my Rails application that uses Authlogic. I
I am using jQuery and want to make it possible for the user to
I am doing some significant refactoring and feature-adding on a project, and have just
I'm still new to git, so bear with me. I started adding a feature
Context: I'm working on master adding a simple feature. After a few minutes I
I am adding a webpart to the webpart gallery as part of a feature
I am creating an application. I have to implement a bookmark feature, and adding

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.