By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,917 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,917 IT Pros & Developers. It's quick & easy.

increment a var

mickey0
100+
P: 142
Expand|Select|Wrap|Line Numbers
  1.  for (var i in data.value.items) { 
  2.    Number = "<b><i> Number: " + (i +1) + "</i></b><br /><br />";
  3. }
  4.  
Hi, I have this code, but I need augmenting by "1" the result; in my output web page appear:
01
11
21
31
41
......
How to solve? thanks...
Jan 24 '08 #1
Share this Question
Share on Google+
3 Replies


10K+
P: 13,264
Expand|Select|Wrap|Line Numbers
  1.  for (var i in data.value.items) { 
  2.    Number = "<b><i> Number: " + (i +1) + "</i></b><br /><br />";
  3. }
  4.  
Hi, I have this code, but I need augmenting by "1" the result; in my output web page appear:
01
11
21
31
41
......
How to solve? thanks...
What are you trying to display? The data items numbered from 0 upwards?
If that is the code that produced that output, then why was "Number" not printed as well?
Perhaps if you explain further what you want to do and post more of the code you are using( in code tags).
Jan 24 '08 #2

mickey0
100+
P: 142
hello,
I want:
1
2
3
4
and not
01
11
21
31
41
Jan 24 '08 #3

gits
Expert Mod 5K+
P: 5,329
hi ...

i guess that i is a string so try:

Expand|Select|Wrap|Line Numbers
  1. for (var i in data.value.items) { 
  2.     Number = "<b><i> Number: " + (parseInt(i, 10) + 1) + "</i></b><br /><br />";
  3. }
kind regards
Jan 24 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.