Reputation: 9
var Mydata= [
{
value: 1,
label: "One"
},
{
value: 2,
label: "Two"
},
{
value: 3,
label: "Three"
},
{
value: 4,
label: "Four"
},
{
value: 5,
label: "Five"
}
];
i need to create this dyanamically using js or jquery
Upvotes: 0
Views: 44
Reputation: 36609
In
loop
, pushobject
inarray
. To get equivalent of the number in words usetoWords.js
Try this:
var len = 10;
var Mydata = [];
for (var i = 1; i < len; i++) {
Mydata.push({
value: i,
label: toWords(i.toString())
});
}
console.log(Mydata);
<script src="http://gh-canon.github.io/stack-snippet-console/console.min.js"></script>
<script src="http://javascript.about.com/library/toword.js"></script>
Upvotes: 1