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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:44:09+00:00 2026-06-02T10:44:09+00:00

I have a list: <select id = opt> <option value=a>a</option> <option value=b>b</option> <option value=c>c</option>

  • 0

I have a list:

<select id = "opt">
  <option value="a">a</option>
  <option value="b">b</option>
  <option value="c">c</option>
</select>

lets do this:

alert (document.getElementById('opt').innerHTML);

it will print that:

<select id = "opt"><option value="a">a</option><option value="b">b</option><option value="c">c</option></select>

no problem yet. Now I change the selected item:

for (var count = 0; count < document.getElementById('opt').childNodes[0].options.length; count++)
{
 if (document.getElementById('opt').childNodes[0].options[count].value == 'b') { document.getElementById('opt').childNodes[0].options[count].selected = true; break; }
}

and print it again:

alert (document.getElementById('opt').innerHTML);

it again will print:

<select id = "opt"><option value="a">a</option><option value="b">b</option><option value="c">c</option></select>

but I excepted something like that!

<select id = "opt"><option value="a">a</option><option value="b" **selected="selected"**>b</option><option value="c">c</option></select>

so .innerHTML doesnt follow the changes. How to fix it?

  • 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-02T10:44:10+00:00Added an answer on June 2, 2026 at 10:44 am

    What you see is the difference between properties and attributes. The selected attribute is copied into the selected property when the element is created. You are changing the property, but that doesn’t change the attribute.

    You can see the difference between setting the property and the attrute here:

    http://jsfiddle.net/Guffa/Pec9j/

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

Sidebar

Related Questions

I have a list like this: <select name=select_list_name id=list_id> <option value=>Select Option</option> <option value=value1>Option
I have a select list that's default value (for Please Select) is 0. this
I have select list items looking like this: <option>- Data source A -</option> <option>-
I have a select list: <select id=filter> <option value=Open selected=selected>Open</option> <option value=Closed>Closed</option> </select> When
I have list select: <select id=sel> <option id=a1 value=volvo>Volvo</option> <option id=a2 value=saab>Saab</option> <option id=a3
I have a list of option inside select list, also I have textfield that
Hi I have a Select list liek so: <select id=cardtype name=cardtype> <option selected='y' value=debit-0.00-50.00>Debit1</option>
I have a select list: <select name=taxonomy[1][] multiple=multiple class=form-select id=edit-taxonomy-1 size=7> <option value=0>None</option> <option
I have a select list like so: <select id=drpColours> <option value= selected=selected>Choose color</option> <option
I have a multi select dropdown eg: <select id=myList multiple=multiple> <option value=1>Opt #1</option> <option

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.