JavaScript - Countup In Dollars
newbie trying to add a for sale "price" countup javascript (to my artwork) which goes up say $5 a day. Also need to start from different prices. Each piece of artwork will be on it's own page. Any ideas?
Similar TutorialsHi guys, hope this is the right place to post my javascript query.... Basically, I want my countup timer to start from when the page is loaded so eg 0 in all fields... This is what i have so far: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Count?</title> <style type="text/css"> .main { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 68px; font-style: normal; font-weight: 400; color: #000; background-color: #FFF; text-align: center; } </style> <script type="text/javascript"> function showElapsedTime() { var startYear = "0"; var startMonth = "0"; // must be between 0 - 11 var startDay = "0"; // must be between 1 - 31 var startHour = "0"; // must be between 0 - 23 var startMinute = "0"; // must be between 0 - 59 var startSecond = "0"; // must be between 0 - 59 var startDate = new Date(); startDate.setYear(startYear); startDate.setMonth(startMonth); startDate.setDate(startDay); startDate.setHours(startHour); startDate.setMinutes(startMinute); startDate.setSeconds(startSecond); var rightNow = new Date(); var elapsedTime = rightNow.getTime() - startDate.getTime(); var one_day=1000*60*60*24; var elapsedDays = Math.floor( elapsedTime / one_day ); var milliSecondsRemaining = elapsedTime % one_day; var one_hour = 1000*60*60; var elapsedHours = Math.floor(milliSecondsRemaining / one_hour ); milliSecondsRemaining = milliSecondsRemaining % one_hour; var one_minute = 1000*60; var elapsedMinutes = Math.floor(milliSecondsRemaining / one_minute ); milliSecondsRemaining = milliSecondsRemaining % one_minute; var one_second = 1000; var elapsedSeconds = Math.round(milliSecondsRemaining / one_second); document.getElementById('elapsedTime').innerHTML = elapsedDays + " Days " + elapsedHours + " Hours " + elapsedMinutes + " Minutes " + elapsedSeconds + " Seconds"; t = setTimeout('showElapsedTime()',1000); } </script> </head> <body onload="showElapsedTime()"> <p class="main"> COUNT: </p> <div id="elapsedTime"></div> </body> </html> Can't quite figure out where i have gone wrong! Thanks in advance! Carl I want to get started in javascript, and while I can do html, some dhtml, and learned (and forgot) cobol, assembly and fortran, I'm not 'getting' it. so I thought if I could start with something I want to do, and see the script for it, rather than figure out what other scripts are doing, that might work better. Suppose I wanted to start at a fixed number, and count up by a randomized +1 or +2 every 12 hours, from now till forever, and display the resultant number. If starting with <script language="javascript"> Countup(); </script> What next? |