pocketmikey

12-09-2010, 06:08 AM

Hello all!

For the past few days I've been having trouble trying to figure out how to do something. I want to code a world population clock similar to the one here (http://www.ibiblio.org/lunarbin/worldpop), but simpler: I want the user to be able to choose future years up to 2020 (just years, not months/days), and have the population grow by 1 percent each year.

So far I have a code for the world population, but I have no clue where to begin in terms of making a list of the years with the option to increase the population.

Could anyone point me in the right direction? I'd appreciate any help!

Heres the code I have:

<body>

<script type="text/javascript">

function maind(){

startdate = new Date()

now(startdate.getYear(),startdate.getMonth(),startdate.getDate(),startdate.getHours(),startdate.getM inutes(),startdate.getSeconds())

}

function ChangeValue(number,pv){

numberstring =""

var j=0

var i=0

while (number > 1)

{

numberstring = (Math.round(number-0.5) % 10) + numberstring

number= number / 10

j++

if (number > 1 && j==3) {

numberstring = "," + numberstring

j=0}

i++

}

numberstring=numberstring

if (pv==1) {document.getElementById("worldpop").innerHTML=numberstring }

}

function now(year,month,date,hours,minutes,seconds){

startdatum = new Date(year,month,date,hours,minutes,seconds)

var now = 5600000000.0

var now2 = 5690000000.0

var groeipercentage = (now2 - now) / now *100

var groeiperseconde = (now * (groeipercentage/100))/365.0/24.0/60.0/60.0

nu = new Date ()

schuldstartdatum = new Date (96,1,1)

secondenoppagina = (nu.getTime() - startdatum.getTime())/1000

totaleschuld= (nu.getTime() - schuldstartdatum.getTime())/1000*groeiperseconde + now

ChangeValue(totaleschuld,1);

timerID = setTimeout("now(startdatum.getYear(),startdatum.getMonth(),startdatum.getDate(),startdatum.getHours(),startdatum .getMinutes(),startdatum.getSeconds())",200)

}

window.onload=maind

</script>

Current world population (estimated): <span id="worldpop" style="font-weight: bold"></span>.

</body>

For the past few days I've been having trouble trying to figure out how to do something. I want to code a world population clock similar to the one here (http://www.ibiblio.org/lunarbin/worldpop), but simpler: I want the user to be able to choose future years up to 2020 (just years, not months/days), and have the population grow by 1 percent each year.

So far I have a code for the world population, but I have no clue where to begin in terms of making a list of the years with the option to increase the population.

Could anyone point me in the right direction? I'd appreciate any help!

Heres the code I have:

<body>

<script type="text/javascript">

function maind(){

startdate = new Date()

now(startdate.getYear(),startdate.getMonth(),startdate.getDate(),startdate.getHours(),startdate.getM inutes(),startdate.getSeconds())

}

function ChangeValue(number,pv){

numberstring =""

var j=0

var i=0

while (number > 1)

{

numberstring = (Math.round(number-0.5) % 10) + numberstring

number= number / 10

j++

if (number > 1 && j==3) {

numberstring = "," + numberstring

j=0}

i++

}

numberstring=numberstring

if (pv==1) {document.getElementById("worldpop").innerHTML=numberstring }

}

function now(year,month,date,hours,minutes,seconds){

startdatum = new Date(year,month,date,hours,minutes,seconds)

var now = 5600000000.0

var now2 = 5690000000.0

var groeipercentage = (now2 - now) / now *100

var groeiperseconde = (now * (groeipercentage/100))/365.0/24.0/60.0/60.0

nu = new Date ()

schuldstartdatum = new Date (96,1,1)

secondenoppagina = (nu.getTime() - startdatum.getTime())/1000

totaleschuld= (nu.getTime() - schuldstartdatum.getTime())/1000*groeiperseconde + now

ChangeValue(totaleschuld,1);

timerID = setTimeout("now(startdatum.getYear(),startdatum.getMonth(),startdatum.getDate(),startdatum.getHours(),startdatum .getMinutes(),startdatum.getSeconds())",200)

}

window.onload=maind

</script>

Current world population (estimated): <span id="worldpop" style="font-weight: bold"></span>.

</body>