I would like to start by saying I am very new to jquery and javascript I rarely use it, however I now find myself in a position where I need to make use of it.
What I am trying to do
I am trying to let admin-user upload matches to db for a round in a competition, thus building the schedule for round X....hope that makes sense
What should happen
if user selects, as an example, 4 from the dropdown box 8 input fields should be created, thus allowing user to enter the 2 teams which will play in each round in each match.
I have tried to code this, (please dont laugh) but the logic and code is completely wrong, if anyone can be so kind to assist me with this problem it would be much appreciated, possibly allowing me to build from this in the future.
JFiddle
https://jsfiddle.net/leela89/zvss0f8L/#&togetherjs=RApSQ2E6Sr
Code
<select id="nrGames" name="nrGame">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<script type="text/javascript">
//create input element for nr games
$("#nrGames").change(function(){
var value = $(this).val;
var nr = 0;
while(nr < value){
$('#games').add('input');
nr++;
}
})
</script>
<!--APPEND INOUT TEXT -->
<div id="games">
</div>