If...Else and variables and counts

T

Tank

I am trying to incorporate a count into a variable within an if...else
statement. Here is the code. I cant get it to work. perhaps someone
can assist me.

folder = window.prompt('starting folder','default');
picnumber = window.prompt('pictures taken?','default');
f2 = parseFloat(folder);
p2 = parseFloat(picnumber);


varAdd = f2+p2-1;
varImg = p2;
var9 = '000';
var99 = '00';
var999 = '0';
var9999 = '0000';

for (count1=f2;count1<=varAdd;count1++)
if (count1 <=9)
varFc = var9999 + count1 +;
else if (count1 <=99)
varFc = var9 + count1 +;
else if (count1 <=999)
varFc = var99 + count1 +;
else if (count1 <=9999)
varFc = var999 + count1 +;
else
varFc = + count +;
document.write('mkdir',varFc,'<br>');
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen
in news:comp.lang.javascript said:
I am trying to incorporate a count into a variable within an if...else
statement. Here is the code. I cant get it to work. perhaps someone
can assist me.

You appear to be trying to count with leading zeroes.

To do that most readily, increase the count by, say, one billion; and
after converting to a string use substring() to remove unwanted leading
digits. If the count K is 7,

document.write('mkdir', String(1e12+K).substr(9), '<br>')

will write mkdir0007 .

But evidently you need to study javascript syntax, as well as
algorithms.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top