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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:16:13+00:00 2026-06-14T10:16:13+00:00

HTML <select name=select id=select> <option value=1>1</option> <option value=2>2</option> <option value=3>3</option> <option value=4>4</option> </select> <br>

  • 0

HTML

<select name="select" id="select">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
</select>
<br>
<input id="bla" type="text" name="attendant[]">

JQuery

$("select").change(function() {

    var select = parseFloat($('#select').val());
    $('#bla').after('<br><input id="bla" type="text" name="attendant[]">');

 });​

Hi guys, above is the code I created.
I need the select box on change to update the the number of form field base on the value of the select box. If user change to 4 there should be 4 form field display on screen. If value change to 1 there should only be one on the screen.

Not so good with JQuery just started few days ago so any help is appreciated.

Thanks

Here is the JSFiddle I’m working on.
http://jsfiddle.net/andrewvmail/b5Gqg/3/

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

    Try this

    HTML

       <select name="select" id="select">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
    </select>
    <br>
    <div class="template" style="display:none">
       <input type="text" name="attendant[]" />
    </div>
    <div id="container" >
    
    </div>
    

    Javascript

    $("select").change(function() {
    
        var select = parseInt($('#select').val() , 10);
        var $clone = $('.template').clone().html();
        console.log($clone);
        var html = '';
        for(var i = 0;i< select ; i++){
            html += $clone;
        }
        $('#container').empty().html(html);
     }).change();​
    

    You can achieve the same without using .clone() .. That was unnecessary..

    $("select").change(function() {
    
        var select = parseInt($('#select').val() , 10);
        var $clone = $('.template').html();
        var html = '';
        while(select > 0){
            html += $clone;
            select--;
        }
        $('#container').empty().html(html);
     }).change();​
    

    Check Fiddle

    Without clone

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

Sidebar

Related Questions

I have a classic HTML select box: Show: <select name=show id=showThreads> <option value=all selected=selected>All</option>
HTML: <form> <input type=radio name=grade value=95 /> A<br /> <input type=radio name=grade value=85 />
I have the following script: <script type=text/javascript> $(document).ready(function(){ $(#ProjModelChoose).change(function() { $(#ProjModelChooseCOM).attr(name,form + $(this).val()); $(input[name='buyid']).attr(value,
my select option in HTML is, <select name=id id=id style=width:400px; onChange=loadAjax(this.value);> <select name=name id=name
Here an example $newattribute.children(div).children(input,select).each(function (i) { var $currentElem = $(this); $currentElem.attr(name, $currentElem.attr(name) + current);
I have an input box like the following: <input type=text value= somethingSpecial=filename.txt id=myID class=box>
So I have the following html: <div id=divForComponents> <input type=button value=+ onclick=addFilter('divForComponents')/> </div> And
I have a simple html form: <form action="/api/userattributes" method=get> <select name=action> <option>read_by_user</option> <option>set</option> <option>delete</option>
I cannot get my addslashes function and html option value to play nice together.
The webkit html select element uses a checkmark to denote a selected option. I

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.