results.jsReturn to the Documentation page
  

‘The results.js file is a javascript file which gets called when the otherstats.aspx file is loaded on the user’s machine – see otherstats.aspx for further details. The file sets up an array named ‘result’ where each index of the array contains a previous election result – all the results going back to 1832 are included. The push method puts each individual result into the array – result[0] will be the General Election result for 1987 and similarly result[1] will contain General Election 1959.’

‘The result used is chosen at random by the last line in this file - document.write(result[(Math.floor(Math.random() * result.length))]); - once the various Math functions have chosen an index number at random, the document.write function then writes the contents of that result to the table cell in otherstats.aspx via a <script>..</script> tag.’

var result = new Array;

result.push("General Election 1987<p><table><tr><td>Con</td><td align=right>376</td></tr><tr><td>Lab</td><td align=right>229</td></tr><tr><td>Lib Dem</td><td align=right>17</td></tr><tr><td>SDP</td><td align=right>5</td></tr><tr><td>SNP</td><td align=right>3</td></tr><tr><td>PC</td><td align=right>3</td></tr><tr><td>Others</td><td align=right>17</td></tr></table><p>PM: Margaret Thatcher");

 

result.push("General Election 1959<p><table><tr><td>Con</td><td align=right>365</td></tr><tr><td>Lab</td><td align=right>258</td></tr><tr><td>Lib</td><td align=right>6</td></tr><tr><td>Others</td><td align=right>1</td></tr></table><p>PM: Harold Macmillan");

 

result.push("General Election 1964<p><table><tr><td>Lab</td><td align=right>317</td></tr><tr><td>Con</td><td align=right>304</td></tr><tr><td>Lib</td><td align=right>9</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>PM: Harold Wilson");

 

result.push("General Election 1966<p><table><tr><td>Lab</td><td align=right>364</td></tr><tr><td>Con</td><td align=right>253</td></tr><tr><td>Lib</td><td align=right>12</td></tr><tr><td>Others</td><td align=right>1</td></tr></table><p>PM: Harold Wilson");

 

result.push("General Election 1970<p><table><tr><td>Con</td><td align=right>330</td></tr><tr><td>Lab</td><td align=right>288</td></tr><tr><td>Lib</td><td align=right>6</td></tr><tr><td>SNP</td><td align=right>1</td></tr><tr><td>Others</td><td align=right>5</td></tr></table><p>PM: Edward Heath");

 

result.push("General Election 1974 (Feb)<p><table><tr><td>Lab</td><td align=right>301</td></tr><tr><td>Con</td><td align=right>297</td></tr><tr><td>Lib</td><td align=right>14</td></tr><tr><td>SNP</td><td align=right>7</td></tr><tr><td>PC</td><td align=right>2</td></tr><tr><td>Others</td><td align=right>14</td></tr></table><p>PM: Harold Wilson");

 

result.push("General Election 1974 (Oct)<p><table><tr><td>Lab</td><td align=right>319</td></tr><tr><td>Con</td><td align=right>277</td></tr><tr><td>Lib</td><td align=right>13</td></tr><tr><td>SNP</td><td align=right>11</td></tr><tr><td>PC</td><td align=right>3</td></tr><tr><td>Others</td><td align=right>12</td></tr></table><p>PM: Harold Wilson");

 

result.push("General Election 1979<p><table><tr><td>Con</td><td align=right>339</td></tr><tr><td>Lab</td><td align=right>269</td></tr><tr><td>Lib</td><td align=right>11</td></tr><tr><td>PC</td><td align=right>2</td></tr><tr><td>SNP</td><td align=right>2</td></tr><tr><td>Others</td><td align=right>12</td></tr></table><p>PM: Margaret Thatcher");

 

result.push("General Election 1983<p><table><tr><td>Con</td><td align=right>397</td></tr><tr><td>Lab</td><td align=right>209</td></tr><tr><td>Lib</td><td align=right>17</td></tr><tr><td>SDP</td><td align=right>6</td></tr><tr><td>SNP</td><td align=right>2</td></tr><tr><td>PC</td><td align=right>2</td></tr><tr><td>Others</td><td align=right>17</td></tr></table><p>PM: Margaret Thatcher");

 

result.push("General Election 1955<p><table><tr><td>Con</td><td align=right>345</td></tr><tr><td>Lab</td><td align=right>277</td></tr><tr><td>Lib</td><td align=right>6</td></tr><tr><td>Others</td><td align=right>2</td></tr></table><p>PM: Sir Anthony Eden");

 

result.push("General Election 1951<p><table><tr><td>Con</td><td align=right>321</td></tr><tr><td>Lab</td><td align=right>295</td></tr><tr><td>Lib</td><td align=right>6</td></tr><tr><td>Others</td><td align=right>3</td></tr></table><p>PM: Sir Winston Churchill");

 

result.push("General Election 1950<p><table><tr><td>Lab</td><td align=right>315</td></tr><tr><td>Con</td><td align=right>298</td></tr><tr><td>Lib</td><td align=right>9</td></tr><tr><td>Others</td><td align=right>3</td></tr></table><p>PM: Clement Atlee");

 

result.push("General Election 1945<p><table><tr><td>Lab</td><td align=right>393</td></tr><tr><td>Nat</td><td align=right>210</td></tr><tr><td>Lib</td><td align=right>12</td></tr><tr><td>ILP</td><td align=right>3</td></tr><tr><td>Comm</td><td align=right>2</td></tr><tr><td>Others</td><td align=right>20</td></tr></table><p>PM: Clement Atlee");

 

result.push("General Election 1935<p><table><tr><td>Nat</td><td align=right>429</td></tr><tr><td>Lab</td><td align=right>154</td></tr><tr><td>Lib</td><td align=right>21</td></tr><tr><td>ILP</td><td align=right>4</td></tr><tr><td>Comm</td><td align=right>1</td></tr><tr><td>Others</td><td align=right>6</td></tr></table><p>PM: Stanley Baldwin");

 

result.push("General Election 1931<p><table><tr><td>Nat</td><td align=right>554</td></tr><tr><td>Lab</td><td align=right>52</td></tr><tr><td>Ind Lib</td><td align=right>4</td></tr><tr><td>Others</td><td align=right>5</td></tr></table><p>PM: Ramsay MacDonald");

 

result.push("General Election 1929<p><table><tr><td>Lab</td><td align=right>287</td></tr><tr><td>Con</td><td align=right>260</td></tr><tr><td>Lib</td><td align=right>59</td></tr><tr><td>Others</td><td align=right>9</td></tr></table><p>PM: Ramsay MacDonald");

 

result.push("General Election 1924<p><table><tr><td>Con</td><td align=right>412</td></tr><tr><td>Lab</td><td align=right>151</td></tr><tr><td>Lib</td><td align=right>40</td></tr><tr><td>Const</td><td align=right>7</td></tr><tr><td>Comm</td><td align=right>1</td></tr><tr><td>Others</td><td align=right>4</td></tr></table><p>PM: Stanley Baldwin");

 

result.push("General Election 1923<p><table><tr><td>Con</td><td align=right>258</td></tr><tr><td>Lab</td><td align=right>191</td></tr><tr><td>Lib</td><td align=right>158</td></tr><tr><td>Others</td><td align=right>8</td></tr></table><p>PM: Ramsay MacDonald");

 

result.push("General Election 1922<p><table><tr><td>Con</td><td align=right>344</td></tr><tr><td>Lab</td><td align=right>142</td></tr><tr><td>Lib</td><td align=right>62</td></tr><tr><td>Nat Lib</td><td align=right>53</td></tr><tr><td>Comm</td><td align=right>1</td></tr><tr><td>Others</td><td align=right>13</td></tr></table><p>PM: Andrew Bonar Law");

 

result.push("General Election 1918<p><table><tr><td>Coalition&nbsp;&nbsp;</td><td align=right>473</td></tr><tr><td>Sinn Fein</td><td align=right>73</td></tr><tr><td>Lab</td><td align=right>57</td></tr><tr><td>Con</td><td align=right>50</td></tr><tr><td>Lib</td><td align=right>36</td></tr><tr><td>Others</td><td align=right>18</td></tr></table><p>PM: David Lloyd George");

 

result.push("General Election 1910 (Dec)<p><table><tr><td>Lib</td><td align=right>272</td></tr><tr><td>Con & LU&nbsp;&nbsp;</td><td align=right>271</td></tr><tr><td>Irish Nat</td><td align=right>84</td></tr><tr><td>Lab</td><td align=right>42</td></tr><tr><td>Others</td><td align=right>1</td></tr></table><p>PM: Herbert Asquith");

 

result.push("General Election 1910 (Jan)<p><table><tr><td>Lib</td><td align=right>274</td></tr><tr><td>Con & LU&nbsp;&nbsp;</td><td align=right>272</td></tr><tr><td>Irish Nat</td><td align=right>82</td></tr><tr><td>Lab</td><td align=right>40</td></tr><tr><td>Others</td><td align=right>2</td></tr></table><p>PM: Herbert Asquith");

 

result.push("General Election 1906<p><table><tr><td>Lib</td><td align=right>399</td></tr><tr><td>Con & LU&nbsp;&nbsp;</td><td align=right>156</td></tr><tr><td>Irish Nat</td><td align=right>82</td></tr><tr><td>Lab</td><td align=right>29</td></tr><tr><td>Others</td><td align=right>4</td></tr></table><p>PM: Sir Henry Campbell-Bannerman");

 

result.push("General Election 1900<p><table><tr><td>Con & LU&nbsp;&nbsp;</td><td align=right>402</td></tr><tr><td>Lib</td><td align=right>183</td></tr><tr><td>Irish Nat</td><td align=right>82</td></tr><tr><td>Lab</td><td align=right>2</td></tr><tr><td>Others</td><td align=right>1</td></tr></table><p>PM: The Marquess of Salisbury");

 

result.push("General Election 1895<p><table><tr><td>Con & LU&nbsp;&nbsp;</td><td align=right>411</td></tr><tr><td>Lib</td><td align=right>177</td></tr><tr><td>Irish Nat</td><td align=right>82</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>PM: The Marquess of Salisbury");

 

result.push("General Election 1892<p><table><tr><td>Con & LU&nbsp;&nbsp;</td><td align=right>313</td></tr><tr><td>Lib</td><td align=right>272</td></tr><tr><td>Irish Nat</td><td align=right>81</td></tr><tr><td>Others</td><td align=right>4</td></tr></table><p>PM: William Gladstone");

 

result.push("General Election 1886<p><table><tr><td>Con & LU&nbsp;&nbsp;</td><td align=right>393</td></tr><tr><td>Lib</td><td align=right>192</td></tr><tr><td>Irish Nat</td><td align=right>85</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>PM: The Marquess of Salisbury");

 

result.push("General Election 1885<p><table><tr><td>Lib</td><td align=right>319</td></tr><tr><td>Con</td><td align=right>249</td></tr><tr><td>Irish Nat</td><td align=right>86</td></tr><tr><td>Others</td><td align=right>16</td></tr></table><p>PM: William Gladstone");

 

result.push("General Election 1880<p><table><tr><td>Lib</td><td align=right>352</td></tr><tr><td>Con</td><td align=right>237</td></tr><tr><td>Irish Home Ruler</td><td align=right>63</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>William Gladstone");

 

result.push("General Election 1874<p><table><tr><td>Con</td><td align=right>350</td></tr><tr><td>Lib</td><td align=right>242</td></tr><tr><td>Irish Home Ruler</td><td align=right>60</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>PM: Benjamin Disraeli");

 

result.push("General Election 1868<p><table><tr><td>Lib</td><td align=right>387</td></tr><tr><td>Con</td><td align=right>271</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>PM: William Gladstone");

 

result.push("General Election 1865<p><table><tr><td>Lib</td><td align=right>369</td></tr><tr><td>Con</td><td align=right>289</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>PM: The Earl of Derby");

 

result.push("General Election 1859<p><table><tr><td>Lib</td><td align=right>356</td></tr><tr><td>Con & LU&nbsp;&nbsp;</td><td align=right>298</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>PM: Lord Palmerston");

 

result.push("General Election 1857<p><table><tr><td>Whig</td><td align=right>377</td></tr><tr><td>Con & LC&nbsp;&nbsp;</td><td align=right>264</td></tr><tr><td>Others</td><td align=right>13</td></tr></table><p>PM: Lord Palmerston");

 

result.push("General Election 1852<p><table><tr><td>Con & LC&nbsp;&nbsp;</td><td align=right>330</td></tr><tr><td>Whig</td><td align=right>324</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>PM: The Earl of Derby");

 

result.push("General Election 1847<p><table><tr><td>Con & LC&nbsp;&nbsp;</td><td align=right>324</td></tr><tr><td>Whig</td><td align=right>292</td></tr><tr><td>Irish Rep</td><td align=right>36</td></tr><tr><td>Chartist</td><td align=right>1</td></tr><tr><td>Others</td><td align=right>2</td></tr></table><p>PM: Lord John Russell");

 

result.push("General Election 1841<p><table><tr><td>Con</td><td align=right>367</td></tr><tr><td>Whig</td><td align=right>271</td></tr><tr><td>Irish Rep</td><td align=right>20</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>PM: Sir Robert Peel");

 

result.push("General Election 1837<p><table><tr><td>Whig</td><td align=right>344</td></tr><tr><td>Con</td><td align=right>314</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>PM: Lord Melbourne");

 

result.push("General Election 1835<p><table><tr><td>Whig</td><td align=right>385</td></tr><tr><td>Con</td><td align=right>273</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>PM: Lord Melbourne");

 

result.push("General Election 1832<p><table><tr><td>Whig</td><td align=right>441</td></tr><tr><td>Con</td><td align=right>175</td></tr><tr><td>Irish Rep</td><td align=right>42</td></tr><tr><td>Others</td><td align=right>0</td></tr></table><p>PM: Earl Grey");

 

result.push("General Election 1997<p><table><tr><td>Lab</td><td align=right>419</td></tr><tr><td>Con</td><td align=right>165</td></tr><tr><td>Lib Dem</td><td align=right>46</td></tr><tr><td>SNP</td><td align=right>6</td></tr><tr><td>PC</td><td align=right>4</td></tr><tr><td>Others</td><td align=right>19</td></tr></table><p>PM: Tony Blair");

 

result.push("General Election 2001<p><table><tr><td>Lab</td><td align=right>413</td></tr><tr><td>Con</td><td align=right>166</td></tr><tr><td>Lib Dem</td><td align=right>52</td></tr><tr><td>SNP</td><td align=right>5</td></tr><tr><td>PC</td><td align=right>4</td></tr><tr><td>Others</td><td align=right>19</td></tr></table><p>PM: Tony Blair");

 

result.push("General Election 1992<p><table><tr><td>Con</td><td align=right>336</td></tr><tr><td>Lab</td><td align=right>271</td></tr><tr><td>Lib Dem</td><td align=right>20</td></tr><tr><td>PC</td><td align=right>4</td></tr><tr><td>SNP</td><td align=right>3</td></tr><tr><td>Others</td><td align=right>17</td></tr></table><p>PM: John Major");

 

document.write(result[(Math.floor(Math.random() * result.length))]);

***********************************************