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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:14:52+00:00 2026-05-26T04:14:52+00:00

All, This javascript code dynamically adds input boxes based on a user’s selection of

  • 0

All,

This javascript code dynamically adds input boxes based on a user’s selection of a dropdown box. I have it almost where it needs to be, but right now, both the “msds_copy” and “cofa_copy” cases display the same data for “html2” when I test. The “msds_copy” selection should make the 2nd form box say “Region/Language” but instead it’s saying “Batch Number”.

Any ideas why this might be happening?

inquiry_type_onchange: function(e) {
        var place_order = 1,
            order_status = 2,
            telalert_signup = 3,
            invoice_questions = 4,
            msds_copy = 5,
            cofa_copy = 6,
            html = null,
            html2 = null,
            inquiry = e.target,
            id = "inquiry_type_addendum",
            form_row = dojo.query("."+id);

        //Clear any possible previous additions. 
        if (form_row != null)
            form_row.forEach(dojo.destroy);

        //Add the correct new field to the form.
        switch (inquiry.selectedIndex) {
            case place_order:
                html = this.create_form_row(id, "Account Number:");
                break;
            case order_status:
                html = this.create_form_row(id, "Order Number:");
                break;
            case telalert_signup:
                html = this.create_form_row(id, "Account Number:");
                break;
            case invoice_questions:
                html = this.create_form_row(id, "Invoice Number");
                break;
            case msds_copy:
                html = this.create_form_row(id, "Product Name:");
                html2 = this.create_form_row(id + "_2", "Region / Language:");  
            case cofa_copy:
                html = this.create_form_row(id, "Product Name:");
                html2 = this.create_form_row(id + "_2", "Batch Number:");
            default:
        }

        if (html == null) return;
        //Place the new element below the inquiry_type field. 
        var placeat = dojo.byId('buttons');
        dojo.place(html, placeat, "before");
        if(html2!=null)
            dojo.place(html2, placeat, "before");
    },

    create_form_row: function(id, label) {
        //Container
        var a = dojo.create("div", { id: id, className: "question inquiry_type_addendum", style: "padding-top:4px;" });
        //Label
        var b = dojo.create("div", { className: "label", innerHTML: label, style: "margin-top:8px;" }, a);
        //Field
        var c = dojo.create("div", { className: "field" });
        var d = dojo.create("span", { className: "full_number_span span" });
        var e = dojo.create("input", { type: "text", className: "textbox full_number", name: label }, d);
        dojo.place(d, c);
        dojo.place(c, a);
        return a;
    }
});
  • 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-26T04:14:53+00:00Added an answer on May 26, 2026 at 4:14 am

    You’re missing your breaks and the switch case msds_copy is executing then falling through to the next case cofa_copy.

            case msds_copy:
                html = this.create_form_row(id, "Product Name:");
                html2 = this.create_form_row(id + "_2", "Region / Language:");  
                break; // <----
            case cofa_copy:
                html = this.create_form_row(id, "Product Name:");
                html2 = this.create_form_row(id + "_2", "Batch Number:");
                break; // <----
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my JavaScript code: <script> function change(name){ var element = document.all.name.value; } </script>
I have some JavaScript code that dynamically injects an iframe in a given HTML
I have a website that have some javascript code to dynamically load in the
I want to load contents of a DIV dynamically in javascript.I used this code
I don't understand this at all. Here is some Javascript code that works in
I have explained the problem below this code <div id='content'> <div id='help'> blah blah
I have a table which has a button to Add Rows. This button adds
So I have a to-do list of items that are dynamically populated by user
I have a table of data which is generated dynamically with Javascript. Every few
I have code that adds list items to an unordered list, and associated with

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.