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.

-- Rogers Cadenhead

Comments

How to turn on or off Bluetooth device in windows 10 computer system? Vist this Homepage and learn all the important knowledge for free and online.


 

I think this is an informative post and it is very useful and knowledgeable. therefore. I would like to thank you for the efforts you have made in writing this article.
Herbal Incense


 

nike air force 1 canvas grey prize ,off white x nike mercurial vapor 360
nike kd 8 black gold for cheap http://www.geenreettedoen.com/nike-kd-8-black-gold-for-cheap-happy_uk


 

nike air force 1 womens all black ,nike air more uptempo supreme outlet
nationals 2 adam eaton red cool base stitched youth mlb jersey http://www.bettsgallery.com/nationals-2-adam-eaton-red-cool-base-stitched-youth-mlb-jersey- jersey_au


 

My wife and i ended up being really thankful Michael could conclude his investigation through the entire precious recommendations he came across from your web site. It's not at all simplistic to simply be releasing strategies which men and women could have been making money from. And now we do understand we have got you to thank for that. These illustrations you made, the straightforward website menu, the relationships you give support to foster - it is all impressive, and it is helping our son and the family recognize that that topic is satisfying, which is tremendously essential. Thank you for all!
kobe byrant shoes www.kobe-shoes.us.com<>


 

jual adidas ace 15.1 boost ,under armour curry 3 review format
texas rangers memorial day hat 2015 years http://www.chaddhuffman.com/texas-rangers-memorial-day-hat-2015-years-hat_en


 

I simply desired to thank you very much once again. I am not sure the things I might have taken care of without these tactics revealed by you on this problem. It had become a real traumatic setting in my position, but observing the specialized tactic you handled the issue made me to jump over happiness. I'm happy for your service and then sincerely hope you realize what a great job that you are providing instructing some other people thru a blog. I am certain you haven't come across any of us.


 

nike soldier 10 600 ,nike air force 1 premium black quotes
jordan jumpman cap black ops http://www.bnbpilipinas.com/jordan-jumpman-cap-black-ops-hat_dk


 

nike air force 1 elite all star uk ,nike magista obra reinigen que
cincinnati reds flex fit hat embroidery http://www.bettsgallery.com/cincinnati-reds-flex-fit-hat-embroidery-hat_en


 

I would like to show my appreciation to the writer for bailing me out of this type of predicament. Because of scouting through the world-wide-web and seeing suggestions which were not beneficial, I thought my life was over. Being alive without the presence of answers to the difficulties you have sorted out by way of your main report is a critical case, as well as those which may have adversely damaged my career if I hadn't come across your site. Your own personal mastery and kindness in handling every aspect was invaluable. I don't know what I would've done if I had not come upon such a thing like this. I'm able to now relish my future. Thanks very much for your skilled and effective guide. I will not hesitate to refer your web sites to anyone who wants and needs tips about this matter.
nike cortez men www.nikecortez.us.com<>


 

nike air pegasus sneakers usa ,nike shox clearance mens size 13 review
nike blazer high blanco cuero http://www.carvingsaegen.com/nike-blazer-high-blanco-cuero-running_es


 

I needed to create you a very little note to finally thank you so much once again relating to the wonderful views you have shared on this site. It was tremendously open-handed of you to convey freely what exactly a few people might have distributed for an ebook in order to make some dough for themselves, certainly considering the fact that you might have tried it if you ever desired. Those guidelines as well acted to become a good way to realize that most people have a similar keenness the same as mine to know the truth whole lot more with reference to this issue. I'm certain there are lots of more enjoyable instances in the future for many who see your site.
irving shoes www.kyrieirving-shoes.us.com<>


 

I think that thanks for the valuabe information and insights you have so provided here.
uniqueonlinecasino


 

I am definitely enjoying your website. You definitely have some great insight and great stories.
007onlinecasino


 

baskets nike lunar flyknit chukka htm ,mercurial superfly amazon echo
nike kd 9 elite all white uk http://www.savewaterla.com/nike-kd-9-elite-all-white-uk-dominate_en


 

Wow i can say that this is another great article as expected of this blog.Bookmarked this site..
casino-kartenspiele.co


 

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post.
casino-tischspiele.com


 

I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people.
2onlinecasinos.com


 

I together with my pals were found to be analyzing the excellent tips and hints on the website then before long I had an awful suspicion I had not expressed respect to the site owner for those secrets. My women were certainly excited to read them and already have in actuality been making the most of them. Appreciate your genuinely really thoughtful as well as for getting variety of nice themes millions of individuals are really needing to understand about. Our honest regret for not expressing appreciation to you earlier.
yeezy www.yeezy500.us<>


 

nike kobe 9 elite wholesale results ,nike mercurial victory iv cr ic galaxy
femmes nike air max 90 blanc rose http://www.bnbpilipinas.com/femmes-nike-air-max-90-blanc-rose-shoes_fr


 

I am also writing to let you be aware of what a wonderful experience my friend's girl enjoyed going through yuor web blog. She discovered some things, which included what it is like to have an amazing giving mindset to have the rest really easily know just exactly specific grueling matters. You really exceeded our expected results. Many thanks for coming up with the great, safe, educational and as well as unique guidance on your topic to Mary.
air force 1 www.nikeairforce1.us.com<>


 

air huarache hyper punch all black ,nike air jordan 1 mid uk
nike air max 2011 black pink white http://www.steineausrheine.com/nike-air-max-2011-black-pink-white-tailwind_en


 

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


 

Nice to read your article! I am looking forward to sharing your adventures and experiences.
007onlinecasino.net


 

mercurial superfly fg football boots discount ,air jordan 13 9.5
kansas city royals beanie cap upgrades http://www.carvingsaw.com/kansas-city-royals-beanie-cap-upgrades-hat_de


 

nike hyperdunk 2017 flyknit ep ,adidas iniki runner boost core black pink
reebok san diego chargers luis castillo 93 white authentic jersey sale http://www.carvingsaw.com/reebok-san-diego-chargers-luis-castillo-93-white-authentic-jersey-sale- jersey_ca


 

adidas ultra boost red cena ,mercurial superfly nike chile 90
nike air max tavas essential trainers black shoes http://www.savewaterla.com/nike-air-max-tavas-essential-trainers-black-shoes-sneakers_fr


 

nike soldier 10 600 ,nike air force 1 premium black quotes
new york yankees hats wholesale tools http://www.bettsgallery.com/new-york-yankees-hats-wholesale-tools-hat_en


 

nike air max 90 essential nz ,nike air foamposite one 2018
adidas mundial goal black gold white shoes http://www.firehurney.com/adidas-mundial-goal-black-gold-white-shoes-happy_en


 

nike air force 1 canvas grey prize ,off white x nike mercurial vapor 360
ryan purvis blue jersey 83 game women nike new york giants nfl jersey stitched sale http://www.carvingsaw.com/ryan-purvis-blue-jersey-83-game-women-nike-new-york-giants-nfl-jersey- stitched-sale-jersey_uk


 

air jordan womens heels ankle boots ,adidas eqt support 93 micropacer kit
youth nike new england patriots 55 brandon spikes limited white nfl jersey sale http://www.chaddhuffman.com/youth-nike-new-england-patriots-55-brandon-spikes-limited-white-nfl- jersey-sale-jersey_uk


 

nike dunk hi nylon premium ,adidas f50 messi edition
texas rangers hat pins gold http://www.chaddhuffman.com/texas-rangers-hat-pins-gold-hat_it


 

I think that thanks for the valuabe information and insights you have so provided here.
flexible workout


 

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post.
voyance gratuite


 

I think this is an informative post and it is very useful and knowledgeable. therefore. I would like to thank you for the efforts you have made in writing this article.
foam roller for lower back


 

That might be very interesting that use Javascript to Fake Live Election Results, however, I would like to know in details to use some freeware to get things done easier?


 

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


 

Wow i can say that this is another great article as expected of this blog.Bookmarked this site..
casino-automatenspiele


 

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


 

Air Canada Booking


 

Air Canada Contact Number


 

Nice to read your article! I am looking forward to sharing your adventures and experiences.
onlinelottospielen


 

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


 

Add a Comment

These HTML tags are permitted: p, b, i, a, and blockquote. A comment may not include more than three links. Participants in this discussion should note the site's moderation policy.