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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:00:22+00:00 2026-05-31T14:00:22+00:00

I have a series of select boxes whose content is dynamically defined, the options

  • 0

I have a series of select boxes whose content is dynamically defined, the options for the second box being populated depending upon the first selection and so on. The problem I have is that once I have (for example) selected options for the first two select boxes, and then want to start again changing the first selection, the displayed text for the second box remains as it was despite my resetting the options. If I dropdown the second select box the correct (updated) options are present. Example below – you can see that on any change event, I try to set option zero of children select boxes to equal “-” in an attempt to overwrite the historically selected text, but this does not seem to work.

How can I programatically update the displayed select text after resetting options?

   <form name="capacity">
<table>
<tr><td>Type:</td>
  <td><select onchange="onchange1();" id="type">
  <option value="-">-</option>
  <option value="Casing">Casing</option>
  <option value="Tubing">Tubing</option>
  </select></td></tr>

<tr><td>OD:</td>
    <td><select onchange="onchange2()" id="od">
    <option value="-">-</option>
    </select></td></tr>

<tr><td>Weight:</td>
  <td><select id="ppf">
    <option value="-">-</option>
      </select></td></tr></table>

and

    function onchange1() {

var type = (document.capacity.type.value);
var od = (document.capacity.od.value);
var ppf = (document.capacity.ppf.value);


document.capacity.od.options.length = 0
document.capacity.ppf.options.length = 0

document.capacity.od.options[0] = new Option("-", "-");
document.capacity.ppf.options[0] = new Option("-", "-");

if (type == "Tubing") {
    document.capacity.od.options[1] = new Option("1.05", 1.05)
    document.capacity.od.options[2] = new Option("1.315", 1.315)
    document.capacity.od.options[3] = new Option("1.66", 1.66)
}

if (type == "Casing") {
    document.capacity.od.options[1] = new Option("4.5", 4.5)
    document.capacity.od.options[2] = new Option("5", 5)
    document.capacity.od.options[3] = new Option("5.5", 5.5)
}

document.capacity.ppf.value = "-";
}

    function onchange2() {
    var type = (document.capacity.type.value);
    var od = (document.capacity.od.value);

document.capacity.ppf.options.length = 0
document.capacity.ppf.options[0] = new Option("-", "-")

if (type == "Tubing") {
    if (od == 1.05) {
        document.capacity.ppf.options[1] = new Option("1.14", 1.14)
        document.capacity.ppf.options[2] = new Option("1.2", 1.2)
        document.capacity.ppf.options[3] = new Option("1.54", 1.54)
    }
    if (od == 1.315) {
        document.capacity.ppf.options[1] = new Option("1.7", 1.7)
        document.capacity.ppf.options[2] = new Option("1.72", 1.72)
        document.capacity.ppf.options[3] = new Option("1.8", 1.8)
    }
    if (od == 1.66) {
        document.capacity.ppf.options[1] = new Option("2.1", 2.1)
        document.capacity.ppf.options[2] = new Option("2.3", 2.3)
        document.capacity.ppf.options[3] = new Option("2.33", 2.33)
    }
}

if (type == "Casing") {
    if (od == 4.5) {
        document.capacity.ppf.options[1] = new Option("9.5", 9.5)
        document.capacity.ppf.options[2] = new Option("10.5", 10.5)
        document.capacity.ppf.options[3] = new Option("11.6", 11.6)
    }
    if (od == 5) {
        document.capacity.ppf.options[1] = new Option("11.5", 11.5)
        document.capacity.ppf.options[2] = new Option("13", 13)
        document.capacity.ppf.options[3] = new Option("15", 15)
    }
    if (od == 5.5) {
        document.capacity.ppf.options[1] = new Option("14", 14)
        document.capacity.ppf.options[2] = new Option("15.5", 15.5)
        document.capacity.ppf.options[3] = new Option("17", 17)
    }
}
  • 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-31T14:00:24+00:00Added an answer on May 31, 2026 at 2:00 pm

    To set an option use something like:

    // by index
    my_select = document.getElementById("my_select_box");
    my_select.selectedIndex = 0; // set first option
    
    // by value
    var value = "my_option";
    for (var i = 0; i < my_select.options.length; i += 1) {
        if (my_select.options[i].value === value) {
            my_select.selectedIndex = i;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a series of select dropboxes setup, with content that dynamically updates depending
I have a series of select boxes within a table like so: <tr> <td><select></select></td>
I am trying to solve this problem. I have a series of SELECT statements
i have a series of select lists, that i am using to populate text
I have a series of stored procedures that select data from a db. I
I have a series of functions which populate a series of drop down boxes.
I have a series of button tag. SELECT team, COUNT( team ) AS pld,
From VBA I'm setting a series of text boxes to have DSum controlSources: Me.Oct.ControlSource
I am using Python 2.6.4. I have a series of select statements in a
I have a series of PDFs named sequentially like so: 01_foo.pdf 02_bar.pdf 03_baz.pdf etc.

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.