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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:16:19+00:00 2026-05-24T18:16:19+00:00

I declare several select items (about 4-5 dozen) by adding the following string to

  • 0

I declare several select items (about 4-5 dozen) by adding the following string to the page

"<select id='myidxxx'><option>" + default + "</option></select>"

And then add other elements later. The problem is, whether I add other elements or not, there is always a blank element selected at start. I can’t get it to not have one, or to select the default value. I’ve tried

<option selected='selected'>

but with no success. How do I get this to list only the explicity added options (no blank line) and select the default entry?

EDIT: I am using IE8

  • 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-24T18:16:19+00:00Added an answer on May 24, 2026 at 6:16 pm

    Firstly I recommend that you create your elements in JS

    Dynamically creating the select tag and its options is the way I would go about this. I am wonder though are you pulling data from a database or some other location that could be where you are getting the blank from.

    Another possible solution it to iterate over the children of the option tag and not add it if it is a null or empty string.

    for (i = 0; i < options.length; i++) {
        if (options[i] != "" && options[i] != " ") {
            opt = document.createElement("option");
            opt.innerText = options[i];
            opt.value = i;
            selectTag.appendChild(opt);
        }
    }
    

    Here is an example: http://jsfiddle.net/V26P5/2/

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

Sidebar

Related Questions

I've seen some variable declare in VB.net in several way like: print(dim _Foo as
DECLARE @table table(XYZ VARCHAR(8) , id int) INSERT INTO @table SELECT '4000', 1 UNION
Declare: LPWSTR** lines= new LPWSTR*[totalLines]; then i set using: lines[totalLines]=&totalText; SetWindowText(totalChat,(LPWSTR)lines[totalLines]); totalLines++; Now I
declare @servername varchar(2000) set @EmriServerit=(select @@servername) declare @dbname varchar(2000) set @dbname ='Test1' declare @Dir
I declare a static char array, then I pass it to a function. How
Is it possible to declare and manage several custom content types inside one module?
I have got the following SQL statement (SQL Server): DECLARE @atr nvarchar(255), @con nvarchar(1000),
I have web-site (for example shops catalog) with several towns. If User select his
I have this SQL Server query: DECLARE @HoursUsed float SELECT COLUMN_A ,(SELECT (@HoursUsed =
There are several situations where you might override a super class's property. You declare

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.