javascript - Add alphabets dynamically as html row increments

问题描述:

How to ensure i have a dynamic increment of Alphabets in a new cell on left side, next to each cell in a row which is dynamically created based on the option chosen in Select. This newly generated alphabet will be considered as bullet points/serial number for that particular row's text box.

jsfiddle

js code

$(document).ready(function(){

var select = $("#Number_of_position"), table = $("#Positions_names");

for (var i = 1; i <= 100; i++){

select.append('<option value="'+i+'">'+i+'</option>');

}

select.change(function () {

var rows = '';

for (var i = 0; i < $(this).val(); i++) {

rows += "<tr><td><input type='text'></td></tr>";

}

table.html(rows);

});

});

html

<select id="Number_of_position">

</select> <table id="Positions_names">

</table>

网友答案:

This is essentially a base26 question, you can search for an implementation of this in javascript pretty easily - How to create a function that converts a Number to a Bijective Hexavigesimal?