\n

As today's California recall election demonstrates, live election results are a hugely popular feature for many news-oriented Web sites. This evening, I'll be reloading the California Secretary of State site over and over until my carpal tunnel nerves snap like kindling.

Offering live election results can be difficult if you don't have a source providing you this information, preferably in electronic form.

Fortunately, it's possible to use JavaScript to present authentic-looking fake live results that change over the course of Election Day.

Here's how:

First, decide how many votes will be cast in the election and counted on your page during the day. California is expecting around 10 million votes, 2 million of which have already been cast by absentee ballot but will not be counted during the day. So that leaves around 7-8 million votes. Store your total in a variable:

var y = 7850223;

Next, determine the time, in milliseconds since Jan. 1, 1970, at which the first vote should be reported. I accomplished this by publishing a dummy Web page with a three-line script:

var today = new Date();
var t = today.getTime();
document.write("<p>" + t);

This displays the time you need, in milliseconds. Store it as a variable named x. Here's mine, for around 7 a.m. PDT when the polls opened.

var x = 1065535367464;

Store the current time in a variable named t:

var today = new Date();
var t = today.getTime();

For the next step, you need to decide how many hours it will take to report 100 percent of the results. This value also needs to be in milliseconds, which are one-one thousandth of a second. For a 14-hour timeframe, it's 50400000 milliseconds (14 hours * 60 minutes * 60 seconds * 1000 milliseconds).

Using this value, the start time (x), and the current time (t), you can calculate the percentage of the vote that has been reported at the time the page is loaded:

var pct = (t - x) / 50400000;

To prevent the total from exceeding 100 percent after your time period, add this conditional:

if (pct > 1) {
pct = 1;
}

The percentage value will cycle from 0.0 to 1.0 over the course of your time period. Multiply it by 100 to get a percentage from 0 to 100 percent. It also can be used to determine the number of votes counted at any time, based on the total number that will be cast (y).

Store this in a variable named vc:

var vc = Math.floor(y * pct);

The Math.floor() function rounds down to a whole number. Without it, you'd be reporting partial votes, which only happens here in Florida.

Next, decide three things about each ballot item you are faking:

1. The percentage of the vote the item should receive when all votes have been counted.
2. The amount this value should change from the start of counting to the end.
3. Whether the item should be gaining ground during the day or losing it.

The last two things add a bit of variability to the results. If the percentage did not change during the day, your results wouldn't be believable. In a real election, that kind of thing could call the legitimacy of a perceived winner into question, which must not be allowed to happen in a democracy, regardless of the actual vote totals (see Bush v. Gore).

Here's a statement that causes a candidate to start with 12 percent of the vote at the beginning of counting and end up with 17 percent:

var jvp = 12 + (5 * pct);

Here's a statement that causes a candidate to start with 40 percent of the vote and end up with 33 percent:

var kvp = 40 - (7 * pct);

Once you have calculated the current percentage of the vote each item has received, you can use the number of counted votes (vc) to reverse-engineer a vote total for that item: var jv = Math.floor(vc * (jvp / 100));
var kv = Math.floor(vc * (kvp / 100));

The percentages you have calculated will have 5 or more decimal places, which is going to be intimidating to some people. We can't have that. The following JavaScript function will format a number to only two decimal places (like currency): function format(amount)
{
var i = parseFloat(amount);
if(isNaN(i)) { i = 0.00; }
var minus = '';
if(i < 0) { minus = '-'; }
i = Math.abs(i);
i = parseInt((i + .005) * 100);
i = i / 100;
s = new String(i);
if(s.indexOf('.') < 0) { s += '.00'; }
if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
s = minus + s;
return s;
}
To finish, display the values you've calculated in document.write() statements, using the format() method with percentages: document.write("<table border="0" cellpadding="6"><tr valign="top">");
document.write("<tr><td>GARY COLEMAN</td><td>" + gv + "</td><td>" + format(gvp) + "%</td></tr>");
document.write("<tr><td>LARRY FLYNT</td><td>" + lv + "</td><td>" + format(lvp) + "%</td></tr>"); document.write("</tr></table>");

That's all there is to it. Your visitors will appreciate the live election results, which they can reload all day long to see who wins.

Su voto es su voz! Abrazos no drogas!

This tutorial is dedicated to Diebold Election Systems. If your no-paper-trail audit-proof touch-screen ballot tabulating system isn't a Diebold, it doesn't count.

how to preform a website audit

This is my first time i visit here and I found so many interesting stuff in your blog especially it's discussion. thank you.
Kensington escorts

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
internet marketing services nearby

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
como bajar de peso en 1 semana

voyance gratuite par telephone

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
independent london escort

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
elite college

I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing.
writing

I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing.
writing

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
Walmart call in number

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
بک لینک

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
ABC ya

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
agen bola terpercaya

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
188bet welcome offer

Read Rozana Spokesman Punjabi news update on politics, sports, fashion, film industries news, national and international level news.

independent escort

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
bandar poker online

I accidentally saw your post and it attracted me from the first few seconds, it was excellent, hope you have more successful posts. I like this post because it contains a lot of useful information to read, maybe everyone will like me.
Games io 2019, Jogos para crianças 2019, Jogos online 360

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
friv 4 online
abcya xyz free
friv 2017

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.

Thanks for sharing!
Michael | window cleaners near me

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
้happyluke

nike air max 2017 mens all white black nike air flight 89 red and white
softwarevb http://www.softwarevb.com/

ncaa jerseys oklahoma sooners 14 sam bradford red college football jerseys nike mercurial superfly v ag blanc orange pour vente

ncaa jerseys oklahoma sooners 14 sam bradford red college football jerseys nike mercurial superfly v ag blanc orange pour vente

nike air max 2017 mens all white black nike air flight 89 red and white
boatwords http://www.boatwords.com/

ncaa jerseys oklahoma sooners 14 sam bradford red college football jerseys nike mercurial superfly v ag blanc orange pour vente
bionicafit http://www.bionicafit.com/

Hello, interesting blog. Nice share. If you want to book affordable tickets for Flights to Orlando, call at our toll free number. The number is toll free, we provide best discounts for flights to Orlando.

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
Air Condition Repair near me

ncaa jerseys oklahoma sooners 14 sam bradford red college football jerseys nike mercurial superfly v ag blanc orange pour vente
bionicafit http://www.bionicafit.com/

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
printing of corporate shirts

jordan ovo cuffed knit hat pattern air jordan 17 retro hommes
bionicafit http://www.bionicafit.com/

nike air max 2017 mens all white black nike air flight 89 red and white

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
hasil piala eropa 2020

ncaa jerseys oklahoma sooners 14 sam bradford red college football jerseys nike mercurial superfly v ag blanc orange pour vente
softwarevb http://www.softwarevb.com/

nike air max 2017 mens all white black nike air flight 89 red and white
bionicafit http://www.bionicafit.com/

jordan ovo cuffed knit hat pattern air jordan 17 retro hommes
bionicafit http://www.bionicafit.com/

nike air max 2017 mens all white black nike air flight 89 red and white
bionicafit http://www.bionicafit.com/

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
เสื้อเชิ้ต กางเกงยีนส์ ชาย

ncaa jerseys oklahoma sooners 14 sam bradford red college football jerseys nike mercurial superfly v ag blanc orange pour vente
boatwords http://www.boatwords.com/

jordan ovo cuffed knit hat pattern air jordan 17 retro hommes

ncaa jerseys oklahoma sooners 14 sam bradford red college football jerseys nike mercurial superfly v ag blanc orange pour vente

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
domino99

international freight forwarding

nike cortez rojos minnesota twins toddler hat quizlet
softwarevb http://www.softwarevb.com/

nike cortez rojos minnesota twins toddler hat quizlet

nike cortez rojos minnesota twins toddler hat quizlet
hotcooltees http://www.hotcooltees.com/

A developmental odontogenic epithelium lined cyst that occures along the lateral root surface of a vital tooth. Also known a Lateral Radicular Cyst or Lateral Periodontal Cyst. Dental Implants

kobe bryant shoes white nike air max flair blanc jaune pour bon marchÃ©

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
international freight forwarding

nike air jordan 9 women all black blue uk nike magista ii tf blanc jaune
softwarevb http://www.softwarevb.com/

international freight forwarding

nike cortez rojos minnesota twins toddler hat quizlet
boatwords http://www.boatwords.com/

nike cortez rojos minnesota twins toddler hat quizlet
softwarevb http://www.softwarevb.com/

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.
localbitcoins

nike cortez rojos minnesota twins toddler hat quizlet
bionicafit http://www.bionicafit.com/

Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.

Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.
m88

Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success..
Angie the Coach

Awesome and interesting article. Great things you've always shared with us. Thanks. Just continue composing this kind of post.
Divorce coaching

Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.

Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success..
Ereccion total PDF

nike cortez rojos minnesota twins toddler hat quizlet
softwarevb http://www.softwarevb.com/

Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success..
Bitcoin San Antonio

Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.
pornofilmpjes

nike cortez rojos minnesota twins toddler hat quizlet
bionicafit http://www.bionicafit.com/

Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success..
gratis films

Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.
brasil modelos

Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success..
shutterfly

Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.
all4webs

nike cortez rojos minnesota twins toddler hat quizlet
softwarevb http://www.softwarevb.com/

nike air jordan 9 women all black blue uk nike magista ii tf blanc jaune
softwarevb http://www.softwarevb.com/

Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.
Digital Marketing

Yes, blogs are more than just personalized websites that allow you to share vacation pictures or update your family and friends. How to make money from blog websites, however, involves a little bit more...

nike tiempo 11 kobe 9 black white high for cheap

Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success..
gratis films

Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success..
gratis live cams

Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success..
gratis cams

nike vapor street flyknit tout noir rouge nike air max 2019 tout blanc pour bon marchÃ©
softwarevb http://www.softwarevb.com/