Click to See Complete Forum and Search --> : script variable trouble
why this one always alert 10???
i want it to alert from 1-10.... *this is only test*
for (abc=0;abc < 10;abc++) {
document.write('<span onclick="alert(abc)">counting</span><br />');
}
Just a little quotes problem... try this:
<script type="text/javascript">
for (abc=0;abc < 10;abc++) {
document.write('<span onclick="alert('+abc+')">counting</span><br />');
}
</script>
sumyounguy
07-22-2003, 10:17 AM
actually, i think the problem is that in your for loops the document.write is overwriting itself, try document.writeln instead
Nope, that's not the problem. My code works fine.
sumyounguy
07-22-2003, 10:19 AM
Pyro is right too though, make sure you put in your single quotes
sumyounguy
07-22-2003, 10:21 AM
really? nevermind then
wow thank you very much!!
how stupid am i :D