I had someone who did this script (credit Chyno Deluxe) that generate a list of menu whatever we write on the box, the question is, I need to generate a sequence of number that continuously added to it
here is the example needed,
<li id='item1'></li> <li id='item2'></li> <li id='item3'></li> <li id='item4'></li>
the number generated beside item'#' , 1,2,3,4,5,6
I had this that generate number, but it was fixed number, here
$.map($(Array(8)),function(val, i) { return i; })
this one only make like this
1,2,3,4,5,6,7,8
the script
(function($) {
"use strict";
var t2h = {
buildHTML: function() {
var i, list, type = this.htmlSelect.options;
if (type[1].selected) {
//console.log(type[1].text);
list = "<select>";
list += "\n";
for (i = 0; i < this.get_items().length; i++) {
list += " <option>";
list += this.get_items()[i];
list += "</option>";
list += "\n";
}
list += "</select>";
you can see the demo below with jquery code that will generate
<select>
<option>menu 1</option>
<option>menu 2</option>
</select>
I need to improve it by adding tag id='' + number on it, like this
<select>
<option id='item1'>menu 1</option>
<option id='item2'>menu 2</option>
</select>
demo : [a link] http://codepen.io/diden/pen/YwwVKO
Hope I can get help with this here, Thank you guys :)
"string"+27and js will read it as"string27". So just set theidto"item"+numCurrentlyOn, and gee gee. Also, needless jQ, "get them while they're young", etc etc.