JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css">
<div id="infants-data"></div>
JavaScript
function doSomethingUsefulWithField(_id) {
console.log("Selected id "+_id+" "+jQuery('#'+_id).val());
}
var html = '';
for( var i = 1; i <= 10; i++)
{
var currInfantDataField = '' +
'<div class="field">Infant ' + i + ': ' +
'<div style="width:600px">' +
'<select id="infant-' + i + '-title" style="border:solid 1px #cccccc;">'+
'<option selected>--Title--</option>' +
'<option value="master">Master</option>' +
'<option value="miss">Miss</option>' +
'</select>' +
'<input type="text" id="infant-' + i + '-surname" placeholder="Surname" style="width:110px; border:solid 1px #cccccc;">' +
'<input type="text" id="infant-' + i + '-othernames" placeholder="Othernames" style="width:120px; border:solid 1px #cccccc;">' +
'<input type="text" id="infant-' + i + '-birthdate" placeholder="Date of Birth" style="width:120px; border:solid 1px #cccccc;" readonly>' +
'</div>' +
'</div>';
html += currInfantDataField;
}
document.getElementById('infants-data').innerHTML = html;
for (var i=0; i<=10; i++) {
jQuery( "#infant-" + i + "-birthdate", document).datepicker({
changeMonth: true,
changeYear: true,
yearRange:'1900:2015',
onSelect:(function(ii) { return function(){doSomethingUsefulWithField("infant-" + ii + "-birthdate")}
})(i)
});
}