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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:24:16+00:00 2026-06-12T04:24:16+00:00

How can I generate multiple sets of dropdowns and text type input fields (where

  • 0

How can I generate multiple sets of dropdowns and text type input fields (where one set consists of 3 dropdowns and 1 input type=text), based on number of times it has to be generated is by selecting a number from another dropdown.

my code is this :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add New Detail</title>
<link href='http://fonts.googleapis.com/css?family=Orienta' rel='stylesheet' type='text/css'>

<style type="text/css">
#main {
    background-color:#0CF;
    width:600px;
    padding:25px 0;
}

#drop_box_set {
    background:#666;
    width:90%;
    color:#FFF;
    padding:25px 0;
}

</style>
<!------------------------------------------------------------------------------------------------>
<!--------------------------- CHANGE OPTIONS ON CHILD DROPDOWN SCRIPT ---------------------------->
<!------------------------------------------------------------------------------------------------>

<script type="text/javascript">
function setOptions(chosen, selbox) {

selbox.options.length = 0;
if (chosen == " ") {
  selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' ');
setTimeout(setOptions(' ',document.add_new_customer_form.optthree),5);
}
if (chosen == "1") {
  selbox.options[selbox.options.length] = new Option('first choice - option one','11');
  selbox.options[selbox.options.length] = new Option('first choice - option two','12');
setTimeout(setOptions('11',document.add_new_customer_form.optthree),5);
}
if (chosen == "2") {
  selbox.options[selbox.options.length] = new Option('second choice - option one','21');
  selbox.options[selbox.options.length] = new Option('second choice - option two','22');
setTimeout(setOptions('21',document.add_new_customer_form.optthree),5);
}
if (chosen == "3") {
  selbox.options[selbox.options.length] = new Option('third choice - option one','31');
  selbox.options[selbox.options.length] = new Option('third choice - option two','32');
setTimeout(setOptions('31',document.add_new_customer_form.optthree),5);
}
if (chosen == "11") {
  selbox.options[selbox.options.length] = new Option('first choice - option one - sub one','111');
  selbox.options[selbox.options.length] = new Option('first choice - option one - sub two','112');
}
if (chosen == "12") {
  selbox.options[selbox.options.length] = new Option('first choice - option two - sub one','121');
  selbox.options[selbox.options.length] = new Option('first choice - option two - sub two','122');
}
if (chosen == "21") {
  selbox.options[selbox.options.length] = new Option('second choice - option one - sub one','211');
  selbox.options[selbox.options.length] = new Option('second choice - option one - sub two','212');
}
if (chosen == "22") {
  selbox.options[selbox.options.length] = new Option('second choice - option two - sub one','221');
  selbox.options[selbox.options.length] = new Option('second choice - option two - sub two','222');
}
if (chosen == "31") {
  selbox.options[selbox.options.length] = new Option('third choice - option one - sub one','311');
  selbox.options[selbox.options.length] = new Option('third choice - option one - sub two','312');
}
if (chosen == "32") {
  selbox.options[selbox.options.length] = new Option('third choice - option two - sub one','321');
  selbox.options[selbox.options.length] = new Option('third choice - option two - sub two','322');
}
}
</script>

</head>

<body>

<div align="center"><!--DIV ALIGNMENT CENTER START-->

<div id="main"><!--DIV MAIN START-->

<form name="add_new_customer_form" method="post" action="">

<label class="description">Number Of Computer Devices : </label>

            <select name="element_19" class="short_select"> 
                <option value="" selected="selected"></option>
                        <option value="01" >01</option>
                        <option value="02" >02</option>
                        <option value="03" >03</option>
                        <option value="04" >04</option>
                        <option value="05" >05</option>
                        <option value="06" >06</option>
                        <option value="07" >07</option>
                        <option value="08" >08</option>
                        <option value="09" >09</option>
                        <option value="10" >10</option>
                        <option value="11" >11</option>
                        <option value="12" >12</option>
                        <option value="13" >13</option>
                        <option value="14" >14</option>
                        <option value="15" >15</option>

        </select>
<div id="drop_box_individual"><!--DIV DROP_BOX_INDIVIDUAL START-->
<label class="description">Device Type : </label>

            <select name="optone" class="element select medium" style="width:200px;" onchange="setOptions(document.add_new_customer_form.optone.options[document.add_new_customer_form.optone.selectedIndex].value,document.add_new_customer_form.opttwo);">
                <option value=" " selected="selected"> </option>
                        <option value="1">First Choice</option>
                        <option value="2">Second Choice</option>
                        <option value="3">Third Choice</option>
            </select>

</div><!--DIV DROP_BOX_INDIVIDUAL ENDS-->

<div id="drop_box_individual"><!--DIV DROP_BOX_INDIVIDUAL START-->
<label class="description">Device Brand : </label>

            <select name="opttwo" class="element select medium" style="width:200px;" onchange="setOptions(document.add_new_customer_form.opttwo.options[document.add_new_customer_form.opttwo.selectedIndex].value,document.add_new_customer_form.optthree);">
                <option value=" " selected="selected"></option>
            </select>
</div><!--DIV DROP_BOX_INDIVIDUAL ENDS-->

<div id="drop_box_individual"><!--DIV DROP_BOX_INDIVIDUAL START-->
<label class="description">Operating System : </label>

            <select name="optthree" class="element select medium" style="width:200px;">
                <option value=" " selected="selected"></option>
            </select>

</div><!--DIV DROP_BOX_INDIVIDUAL ENDS-->

<div id="drop_box_individual"><!--DIV DROP_BOX_INDIVIDUAL START-->
<label class="description">Serial Number : </label>

            <input name="element_10" class="element text medium" type="text" maxlength="255" value=""/>
</div><!--DIV DROP_BOX_INDIVIDUAL ENDS-->
</form>
</div><!--DIV MAIN ENDS-->
</div><!--DIV ALIGNMENT CENTER ENDS-->

</body>
</html>

Also, here is a link to jsFiddle I came across while searching for a solution.

In this above jsFiddle if one clicks on “add” button it generates a set of 02 dropdowns + 01 type=text input fields and a REMOVE button, in case some one generated more than requirement.

This is what exactly I need, But the difference is that I need it to be a automated process.

What I need is (according to my code):

If 05 is selected from the fist dropdown saying “Number of Computer Devices”, it should generate 05 sets of dropboxes and type=text inputs and remove buttons.

It should generate 05 sets, where 01 set = 03 dropdowns + 01 type=text input field and a remove button if generated more than requiremt.

  • 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-12T04:24:17+00:00Added an answer on June 12, 2026 at 4:24 am

    Add a loop to your code.

    Like this

    JS

    $(function() {
        $("input[type=button][value=Add]").click(function(e) {
            for (i = 0; i < document.getElementById('sel').value; i++) {
                e.preventDefault();
                var newDiv = $("<div>").appendTo("#div");
                $("<input>").attr("name", "a").appendTo(newDiv);
                $("<input>").attr("name", "b").appendTo(newDiv);
                $("<select>").attr("name", "c").appendTo(newDiv).append(
                $("<option>").val("0").text("Option 1"), $("<option>").val("1").text("Option 2"));
                $("<select>").attr("name", "d").appendTo(newDiv).append(
                $("<option>").val("0").text("Option 1"), $("<option>").val("1").text("Option 2"));
                $("<button>").text("Remove").appendTo(newDiv).click(function(e) {
                    e.preventDefault();
                    newDiv.remove();
                })
            }
        })
    })
    

    HTML

    <form>
        <div id="div"></div>
        <select id="sel">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
        <input type="button" value="Add" />
    </form>
    

    See it working here: http://jsfiddle.net/RASG/bYBPD/

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

Sidebar

Related Questions

I have one set of source files from which I need to generate multiple
If multiple grouping is used, jqgrid advanced search can generate search criteria like {groupOp:AND,rules:[],groups:[{groupOp:AND,rules:[{field:Nimi,op:cn,data:kk},{field:Nimi,op:cn,data:kkk}],groups:[]}]}
I can generate my models and schema.yml file based on an existing database. But
I found jquery can generate file tree structure based on existing folders and files
I have multiple sets of points (for different years ~20) I want to generate
How can i generate multiple texts using the imagecreatetruecolor() method? I have the following
I'm using a php loop to generate multiple button elements. How can I determine
When I submit a form in HTML, I can pass a parameter multiple times,
What is an algorithm to compare multiple sets of numbers against a target set
I am trying to create a simple AS3 script which can generate multiple paragraphs,

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.