I have got the power maths thing: document.write(Math.pow(2,1)) document.write(Math.pow(2,2)) document.write(Math.pow(2,3)) document.write(Math.pow(2,4))
I was wondering if there was any way to automaticaly carry on the sequence without writing out the full sequence.
@KravvitzDec 17.2005 — #Sounds like you want to use a for() loop. Use document.write() with caution. var str=''; for(var i=1;i<=4;i++) { str += ((i>1)?', ':'')+Math.pow(2,i); } document.write(str);
@CharlesDec 17.2005 — #<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Power to the People</title> <ol> <script type="text/javascript"> var n, i = 1 while (n = Math.pow (2, i++), n < Number.MAX_VALUE) {document.write ('<li>', n)} </script> </ol>
@tiffeyneohelpauthorDec 17.2005 — #How would you do it so that it had a textbox, and you entered a number into it, and it calculated that number individually
@tiffeyneohelpauthorDec 17.2005 — #<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Content-Script-Type" content="text/javascript"> <title>Power 2 the People</title> <div><input onchange="this.value = Math.pow(2, this.value)" onfocus="this.value = ''" type="text"></div>[/QUOTE] Thanks. I'm not very good at JavaScript