Click to See Complete Forum and Search --> : strange error in my for command


MadCommando
07-04-2003, 10:34 PM
Here's the site http://216.117.199.237/sequential-image-buddy_2-4.html

If your input is
Generate Forum code

B: test
1: 2
2: 10
3: checked
4: 2

itll open the popup and run all the script up until the for command. I tested this by putting some alerts in. My guess is it's a symantics error. Any ideas?

(edit: some of the alerts are still there but don't run)

here's the script that runs, it's a function run on submit, I hope one of you guys can help me out.


function img_gen()
{
output=window.open("","output")
output.focus()

var autoformat0=document.site.format0.value
var autoformat1=document.site.format1.value
var number0=document.site.number0.value
var number1=document.site.number1.value
var digits=document.site.digits.value
var urlpic=document.site.urlpic.value
var filetype=document.site.filetype.value


if (document.site.auto[0].checked) {var autoformat0='<img src="'; var autoformat1='"></img>'}
if (document.site.auto[1].checked) {var autoformat0=''; var autoformat1=''}

for (count1=number0; count1<=number1; count1++)
{
if (document.site.zero.checked)
{
alert("zero's generation")
count1test = count1
var count1len = 0
while (count1test>=1)
{count1test = count1test / 10; count1len = count1len + 1}
output.document.write(count1len)
var addzeros = digits - count1len
for (count2=1; count2 <= addzeros; count2++)
{count1 = "0" + count1;}
alert("digits counted and variable adjusted")
}

output.document.write(autoformat0 + urlpic + count1 + filetype + autoformat1 + "<br>");
}
}

MadCommando
07-05-2003, 08:55 AM
Yeah, so does anyone have any idea why it's not executing?

SlankenOgen
07-05-2003, 12:52 PM
A little nit picking may help. Always end statements with a " ; "

It's not supposed to be necessary but I feel it is always best to follow the rules.

I have made some slight alterations-

for (count1=number0; count1<=number1; count1++)
{
if (document.site.zero.checked == true)
{
alert("zero's generation");
count1test = count1;
var count1len = 0;
while (count1test>=1)
{
count1test = count1test / 10;
count1len = count1len + 1;
}

output.document.write(count1len);
var addzeros = digits - count1len;
for (count2=1; count2 <= addzeros; count2++)
{
count1 = "0" + count1;
}
alert("digits counted and variable adjusted");
}

output.document.write(autoformat0 + urlpic + count1 + filetype + autoformat1 + "<br>");
}
}

MadCommando
07-05-2003, 08:26 PM
Even after nit-picking, it still has no errors, but won't output the stuff. :confused:

here's the tweaked script, I'm guessing it's just a glitch of some sort that isnt fixable.


for (count1=number0; count1<=number1; count1++)
{
if (document.site.zero.checked==true)
{
count1test = count1;
var count1len = 0;
while (count1test>=1) {count1test = count1test / 10; count1len = count1len + 1;}
if (count1==0) {count1len=1}

var addzeros = digits - count1len;

for (count2=1; count2 <= addzeros; count2++) {count1 = "0" + count1;}

//if
}

output.document.write(autoformat0 + urlpic + count1 + filetype + autoformat1 + "<br>");

//for
}

//fnctn
}


I guess it's something we can't fix. :(

SlankenOgen
07-06-2003, 09:29 AM
I prefer to do it this way-

var autoformat0=\"<img src=\"; var autoformat1=\"></img>\"