1

i'm trying to create form based on the dropdown values. i followed this tutorial

here

but it didn't work for me.

any help would be appreciated

JQ example

$("#selectBox").change(function() {
  var htmlString = "";
  var len = $("options:selected", this).val();
  for (var i = 0; i < len; i++) {
    htmlString += "<input type='text' class='email'>";
    htmlString += "<input type='text' class='name'>";
  }
  $("#outputArea").html(htmlString);
}
2
  • didn't work for me is just not enough to know your issues, could you explain the detail? Commented Feb 7, 2014 at 2:34
  • @xdazz i created my own html to work with the JQ, but nothing happened Commented Feb 7, 2014 at 2:38

1 Answer 1

2

Try this,

Demo

<select id="selectBox" >

    <option value=1>one</option>
     <option value=2>two</option>
     <option value=3>three</option>
    <option value=4>four</option>
     <option value=5>five</option>
     <option value=6>six</option>


</select>
<div id="outputArea"></div>

Jquery:

$("#selectBox").change(function() {
  var htmlString = "";
  var len = $(this).val();
  for (var i = 0; i < len; i++) {
    htmlString += "<input type='text' class='email'>";
    htmlString += "<input type='text' class='name'>";
  }

  $("#outputArea").html(htmlString);
})

I hope this will help you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.