Jump to content

ttnaddy16

Members
  • Content count

    13
  • Joined

  • Last visited

Community Reputation

0 Neutral

About ttnaddy16

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I finally got it working the windows onload function wasn't surrounding the function. Thank You Very Much!
  2. I added the javascript code at the end Of my existing javascript code that is linked to my index page but For some reason it will not execute that javascript code Do I have to modify the javascript code you sent me Because I'm linking it to an external Javascript file. Here's my website code <!DOCTYPE html> <html lang="en-us"> <head> <title>W3.CSS</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="styles.css"> <script type="text/javascript" src="naddymyscript.js"></script> </head> <body> <div class="w3-container"> <hr> <div class="w3-center"> <h2>Individual Stats 2016-2017</h2> </div> <div class="w3-responsive w3-card-4"> <table class="w3-table w3-striped w3-bordered" id="otcindividualstatsTable"> <thead> <tr class="w3-theme"> <th data-type="String">Name</th> <th data-type="Number">Grade</th> <th data-type="Number">Wins</th> <th data-type="Number">Losses</th> <th data-type="Number">Win %</th> <th data-type="Number">TD</th> <th data-type="Number">OP TD</th> <th data-type="Number">TD%</th> <th data-type="Number">3 Pt. NF</th> <th data-type="Number">2 Pt. NF</th> <th data-type="Number">Reversals</th> <th data-type="Number">Escapes</th> <th data-type="Number">OP Escapes</th> <th data-type="Number">Escape %</th> <th data-type="Number">Pen. Hm.</th> <th data-type="Number">Pen. Opp.</th> <th data-type="Number">Pins</th> <th data-type="Number">Team Pts.</th> </tr> </thead> <tbody> <tr class="w3-white"> <td>Laredo Bugbee</td> <td>9</td> <td>7</td> <td>14</td> <td>33.33333</td> <td>9</td> <td>24</td> <td>27.27273</td> <td>2</td> <td>0</td> <td>1</td> <td>6</td> <td>4</td> <td>60</td> <td>0</td> <td>0</td> <td>2</td> <td>39</td> </tr> <tr class="w3-gray"> <td>Ben Naddy</td> <td>11</td> <td>38</td> <td>4</td> <td>90.4762</td> <td>23</td> <td>6</td> <td>79.3103</td> <td>8</td> <td>4</td> <td>12</td> <td>10</td> <td>36</td> <td>21.7391</td> <td>1</td> <td>0</td> <td>21</td> <td>255</td> </tr> <tr class="w3-white"> <td>Marc Hendricks</td> <td>11</td> <td>28</td> <td>13</td> <td>68.2927</td> <td>96</td> <td>48</td> <td>66.6667</td> <td>13</td> <td>3</td> <td>7</td> <td>41</td> <td>88</td> <td>31.7829</td> <td>1</td> <td>2</td> <td>4</td> <td>133</td> </tr> <tr class="w3-gray"> <td>Nate Hart</td> <td>11</td> <td>38</td> <td>4</td> <td>90.4762</td> <td>75</td> <td>25</td> <td>75</td> <td>15</td> <td>7</td> <td>11</td> <td>30</td> <td>50</td> <td>37.5</td> <td>1</td> <td>0</td> <td>21</td> <td>239</td> </tr> <tr class="w3-white"> <td>Max Naddy</td> <td>10</td> <td>24</td> <td>16</td> <td>60</td> <td>87</td> <td>22</td> <td>79.8165</td> <td>11</td> <td>3</td> <td>5</td> <td>15</td> <td>62</td> <td>19.4805</td> <td>4</td> <td>1</td> <td>8</td> <td>135</td> </tr> <tr class="w3-gray"> <td>Zane Swanson</td> <td>9</td> <td>21</td> <td>15</td> <td>58.3333</td> <td>22</td> <td>31</td> <td>41.5094</td> <td>3</td> <td>8</td> <td>11</td> <td>16</td> <td>1</td> <td>94.1176</td> <td>0</td> <td>7</td> <td>6</td> <td>112</td> </tr> <tr class="w3-white"> <td>James Holen</td> <td>12</td> <td>15</td> <td>10</td> <td>60</td> <td>34</td> <td>21</td> <td>61.8182</td> <td>7</td> <td>1</td> <td>6</td> <td>21</td> <td>24</td> <td>46.6667</td> <td>2</td> <td>1</td> <td>3</td> <td>74</td> </tr> <tr class="w3-gray"> <td>Alex Erlandson</td> <td>11</td> <td>18</td> <td>13</td> <td>58.0645</td> <td>32</td> <td>33</td> <td>49.2308</td> <td>6</td> <td>3</td> <td>16</td> <td>20</td> <td>18</td> <td>52.6316</td> <td>0</td> <td>1</td> <td>7</td> <td>107</td> </tr> <tr class="w3-white"> <td>Noah Schleske</td> <td>9</td> <td>2</td> <td>2</td> <td>50</td> <td>3</td> <td>7</td> <td>30</td> <td>2</td> <td>0</td> <td>3</td> <td>3</td> <td>5</td> <td>37.5</td> <td>0</td> <td>0</td> <td>1</td> <td>9</td> </tr> <tr class="w3-gray"> <td>Jace Leabo</td> <td>11</td> <td>20</td> <td>23</td> <td>46.5116</td> <td>43</td> <td>41</td> <td>51.1905</td> <td>6</td> <td>4</td> <td>14</td> <td>32</td> <td>45</td> <td>41.5584</td> <td>2</td> <td>1</td> <td>4</td> <td>70</td> </tr> <tr class="w3-white"> <td>Wyatt Thorson</td> <td>9</td> <td>12</td> <td>22</td> <td>35.2941</td> <td>22</td> <td>46</td> <td>32.3529</td> <td>2</td> <td>4</td> <td>13</td> <td>7</td> <td>21</td> <td>25</td> <td>1</td> <td>1</td> <td>3</td> <td>53</td> </tr> <tr class="w3-gray"> <td>Nathan Stavas</td> <td>10</td> <td>2</td> <td>2</td> <td>50</td> <td>1</td> <td>3</td> <td>25</td> <td>0</td> <td>0</td> <td>1</td> <td>1</td> <td>3</td> <td>25</td> <td>0</td> <td>0</td> <td>2</td> <td>10</td> </tr> <tr class="w3-white"> <td>Ramon Lopez</td> <td>11</td> <td>17</td> <td>18</td> <td>48.5714</td> <td>34</td> <td>35</td> <td>49.2754</td> <td>5</td> <td>2</td> <td>3</td> <td>23</td> <td>23</td> <td>50</td> <td>0</td> <td>0</td> <td>10</td> <td>100</td> </tr> <tr class="w3-gray"> <td>Nick Haugen</td> <td>12</td> <td>19</td> <td>25</td> <td>43.1818</td> <td>27</td> <td>34</td> <td>44.2623</td> <td>2</td> <td>2</td> <td>10</td> <td>23</td> <td>16</td> <td>58.9744</td> <td>0</td> <td>1</td> <td>14</td> <td>95</td> </tr> <tr class="w3-white"> <td>RJ Ehlert</td> <td>11</td> <td>13</td> <td>11</td> <td>54.1667</td> <td>11</td> <td>5</td> <td>68.75</td> <td>0</td> <td>0</td> <td>5</td> <td>7</td> <td>6</td> <td>53.8462</td> <td>2</td> <td>0</td> <td>10</td> <td>81</td> </tr> <tr class="w3-gray"> <td>Ben Cole</td> <td>12</td> <td>0</td> <td>3</td> <td>0</td> <td>0</td> <td>5</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>1</td> <td>50</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> </tr> <tr class="w3-white"> <td>Michael Fielding</td> <td>11</td> <td>5</td> <td>14</td> <td>26.3158</td> <td>6</td> <td>21</td> <td>22.2222</td> <td>0</td> <td>0</td> <td>3</td> <td>7</td> <td>12</td> <td>36.8421</td> <td>0</td> <td>1</td> <td>0</td> <td>24</td> </tr> <tr class="w3-gray"> <td>Jacob Thompson</td> <td>12</td> <td>2</td> <td>5</td> <td>28.5714</td> <td>3</td> <td>9</td> <td>25</td> <td>3</td> <td>1</td> <td>1</td> <td>7</td> <td>2</td> <td>77.7778</td> <td>1</td> <td>0</td> <td>1</td> <td>16</td> </tr> <tr class="w3-white"> <td>Hunter Doll</td> <td>10</td> <td>6</td> <td>10</td> <td>37.5</td> <td>10</td> <td>17</td> <td>37.037</td> <td>2</td> <td>0</td> <td>6</td> <td>4</td> <td>11</td> <td>26.6667</td> <td>1</td> <td>0</td> <td>0</td> <td>21</td> </tr> <tr class="w3-gray"> <td>Christopher Kenyon</td> <td>12</td> <td>1</td> <td>2</td> <td>33.3333</td> <td>3</td> <td>3</td> <td>50</td> <td>0</td> <td>0</td> <td>2</td> <td>2</td> <td>3</td> <td>40</td> <td>1</td> <td>0</td> <td>1</td> <td>3</td> </tr> <tr class="w3-white"> <td>Jackson Boyum</td> <td>10</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>3</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>3</td> <td>25</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> </tr> <tr class="w3-gray"> <td>Matt Hendricks</td> <td>9</td> <td>4</td> <td>7</td> <td>36.3636</td> <td>10</td> <td>11</td> <td>47.619</td> <td>2</td> <td>0</td> <td>1</td> <td>3</td> <td>9</td> <td>25</td> <td>2</td> <td>0</td> <td>2</td> <td>21</td> </tr> <tr class="w3-white"> <td>Kevin Tierney</td> <td>11</td> <td>7</td> <td>15</td> <td>31.8182</td> <td>5</td> <td>24</td> <td>17.2414</td> <td>5</td> <td>0</td> <td>3</td> <td>7</td> <td>2</td> <td>77.7778</td> <td>0</td> <td>0</td> <td>1</td> <td>36</td> </tr> <tr class="w3-gray"> <td>Cian Buehler</td> <td>8</td> <td>3</td> <td>6</td> <td>33.3333</td> <td>3</td> <td>5</td> <td>37.5</td> <td>2</td> <td>0</td> <td>4</td> <td>2</td> <td>2</td> <td>50</td> <td>0</td> <td>0</td> <td>5</td> <td>15</td> </tr> <tr class="w3-white"> <td>Hayden Hart</td> <td>9</td> <td>12</td> <td>10</td> <td>54.5455</td> <td>16</td> <td>13</td> <td>55.1724</td> <td>2</td> <td>1</td> <td>5</td> <td>14</td> <td>13</td> <td>51.8519</td> <td>4</td> <td>1</td> <td>2</td> <td>48</td> </tr> <tr class="w3-gray"> <td>Reed Leabo</td> <td>8</td> <td>1</td> <td>2</td> <td>33.3333</td> <td>1</td> <td>5</td> <td>16.6667</td> <td>0</td> <td>1</td> <td>0</td> <td>1</td> <td>2</td> <td>33.3333</td> <td>0</td> <td>0</td> <td>0</td> <td>6</td> </tr> <tr class="w3-white"> <td>Daniel Ukkelberg</td> <td>12</td> <td>1</td> <td>0</td> <td>100</td> <td>0</td> <td>0</td> <td>100</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>6</td> </tr> </tbody> </table> </div> </body> </html> </body> And here's my javascript code That I'm linking to //Tyler Naddy //1/18/17 <!-- Script for Sidenav, Tabs, Accordions, Progress bars and slideshows --> // Side navigation function w3_open() { var x = document.getElementById("mySidenav"); x.style.width = "100%"; x.style.textAlign = "center"; x.style.fontSize = "50px"; x.style.paddingTop = "10%"; x.style.display = "block"; } function w3_close() { document.getElementById("mySidenav").style.display = "none"; } // Tabs function openTab(evt, tabName) { var i, x, tablinks; x = document.getElementsByClassName("tab"); for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } tablinks = document.getElementsByClassName("tablink"); for (i = 0; i < x.length; i++) { tablinks[i].className = tablinks[i].className.replace(" w3-red", ""); } document.getElementById(tabName).style.display = "block"; evt.currentTarget.className += " w3-red"; } var mybtn = document.getElementsByClassName("testbtn")[0]; mybtn.click(); // Accordions function myAccFunc(id) { var x = document.getElementById(id); if (x.className.indexOf("w3-show") == -1) { x.className += " w3-show"; x.previousElementSibling.className += " w3-dark-grey"; } else { x.className = x.className.replace(" w3-show", ""); x.previousElementSibling.className = x.previousElementSibling.className.replace(" w3-dark-grey", ""); } } // Slideshows var slideIndex = 1; function plusDivs(n) { slideIndex = slideIndex + n; showDivs(slideIndex); } function showDivs(n) { var x = document.getElementsByClassName("mySlides"); if (n > x.length) {slideIndex = 1} if (n < 1) {slideIndex = x.length} ; for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } x[slideIndex-1].style.display = "block"; } showDivs(1); // Progress Bars function move() { var elem = document.getElementById("myBar"); var width = 1; var id = setInterval(frame, 10); function frame() { if (width == 100) { clearInterval(id); } else { width++; elem.style.width = width + '%'; document.getElementById("demoprgr").innerHTML = width * 1 + '%'; } } } function openImg(imgName) { var i, x; x = document.getElementsByClassName("picture"); for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } document.getElementById(imgName).style.display = "block"; } (function() { // Javascript can only sort by string value so set up comparison functions for other types var comparators = { }; comparators[typeof "string"] = function(a, b) { return a.localeCompare(b); }; comparators[typeof 123] = function(a, b) { return a - b; }; var table = document.querySelector("table"); var tbody = table.querySelector("tbody"); var types, data; // array of column data types. adds the click handler with sorting too types = Array.from(table.querySelectorAll("thead th")).map(function(th, i) { // basic toggle for sort order on this column var sorting = 0; // click handler th.addEventListener("click", function() { // toggle sort order sorting = (sorting > 0 ? -1 : +1); // perform the sort data.sort(function(a, b) { // compares using whichever of the comparator functions matches the value type return sorting * comparators[typeof a.cells[i]](a.cells[i], b.cells[i]); // and rearrange in the table }).forEach(function(row) { tbody.appendChild(row.row); }); }); return th.attributes["data-type"].value; }); // the data table itself data = Array.from(tbody.querySelectorAll("tr"), function(row) { // each entry is { row: the original <tr>, cells: [ array of values in a native form ] } return { row: row, cells: Array.from(row.querySelectorAll("td")).map(function(cell, i) { // converts the value according to the type/function from the header row return window[types[i]](cell.innerHTML); }) }; }); })(); Now on my end my javascript file that I am linking to is located in a folder called js And the file itself is called naddymyscript.js. I have tried putting that javascript code right in a script Tag on my website and I've tried linking to it externally and both methods have not worked any help on your end would be appreciated otherwise I modified the code in JS fiddlle and it was working I just can't get it working locally on my computer.
  3. I still don't know how to work for a table with 18 columns & 28 rows. If its a table with just 2 rows i can get it to work but for my table it won't work.
  4. I have a table With 28 Rows & 18 Columns and I want every column header to be sortable When you click it and sort the column numerically Except for the first column which is the name column which I want to sort alphabetically. I am using a template off W3.CSS So I'm using there W3.CSS Javascript code to sort tables but I can't seem to get it to work. I will include my table code and the code that I tried to use to sort the table. Any help would be appreciated. Here is my html code <!DOCTYPE html> <html lang="en-us"> <head> <title>W3.CSS</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="styles.css"> <script type="text/javascript" src="naddymyscript.js"></script> </head> <body> <div class="w3-container"> <hr> <div class="w3-center"> <h2>Individual Stats 2016-2017</h2> </div> <div class="w3-responsive w3-card-4"> <table class="w3-table w3-striped w3-bordered" id="otcindividualstatsTable"> <thead> <tr class="w3-theme"> <th onclick="sortTable">Name</th> <th onclick="sortTable">Grade</th> <th onclick="sortTable">Wins</th> <th onclick="sortTable">Losses</th> <th onclick="sortTable">Win %</th> <th onclick="sortTable">TD</th> <th onclick="sortTable">OP TD</th> <th onclick="sortTable">TD%</th> <th onclick="sortTable">3 Pt. NF</th> <th onclick="sortTable">2 Pt. NF</th> <th onclick="sortTable">Reversals</th> <th onclick="sortTable">Escapes</th> <th onclick="sortTable">OP Escapes</th> <th onclick="sortTable">Escape %</th> <th onclick="sortTable">Pen. Hm.</th> <th onclick="sortTable">Pen. Opp.</th> <th onclick="sortTable">Pins</th> <th onclick="sortTable">Team Pts.</th> </tr> </thead> <tbody> <tr class="w3-white"> <td>Laredo Bugbee</td> <td>9</td> <td>7</td> <td>14</td> <td>33.33333</td> <td>9</td> <td>24</td> <td>27.27273</td> <td>2</td> <td>0</td> <td>1</td> <td>6</td> <td>4</td> <td>60</td> <td>0</td> <td>0</td> <td>2</td> <td>39</td> </tr> <tr class="w3-gray"> <td>Ben Naddy</td> <td>11</td> <td>38</td> <td>4</td> <td>90.4762</td> <td>23</td> <td>6</td> <td>79.3103</td> <td>8</td> <td>4</td> <td>12</td> <td>10</td> <td>36</td> <td>21.7391</td> <td>1</td> <td>0</td> <td>21</td> <td>255</td> </tr> <tr class="w3-white"> <td>Marc Hendricks</td> <td>11</td> <td>28</td> <td>13</td> <td>68.2927</td> <td>96</td> <td>48</td> <td>66.6667</td> <td>13</td> <td>3</td> <td>7</td> <td>41</td> <td>88</td> <td>31.7829</td> <td>1</td> <td>2</td> <td>4</td> <td>133</td> </tr> <tr class="w3-gray"> <td>Nate Hart</td> <td>11</td> <td>38</td> <td>4</td> <td>90.4762</td> <td>75</td> <td>25</td> <td>75</td> <td>15</td> <td>7</td> <td>11</td> <td>30</td> <td>50</td> <td>37.5</td> <td>1</td> <td>0</td> <td>21</td> <td>239</td> </tr> <tr class="w3-white"> <td>Max Naddy</td> <td>10</td> <td>24</td> <td>16</td> <td>60</td> <td>87</td> <td>22</td> <td>79.8165</td> <td>11</td> <td>3</td> <td>5</td> <td>15</td> <td>62</td> <td>19.4805</td> <td>4</td> <td>1</td> <td>8</td> <td>135</td> </tr> <tr class="w3-gray"> <td>Zane Swanson</td> <td>9</td> <td>21</td> <td>15</td> <td>58.3333</td> <td>22</td> <td>31</td> <td>41.5094</td> <td>3</td> <td>8</td> <td>11</td> <td>16</td> <td>1</td> <td>94.1176</td> <td>0</td> <td>7</td> <td>6</td> <td>112</td> </tr> <tr class="w3-white"> <td>James Holen</td> <td>12</td> <td>15</td> <td>10</td> <td>60</td> <td>34</td> <td>21</td> <td>61.8182</td> <td>7</td> <td>1</td> <td>6</td> <td>21</td> <td>24</td> <td>46.6667</td> <td>2</td> <td>1</td> <td>3</td> <td>74</td> </tr> <tr class="w3-gray"> <td>Alex Erlandson</td> <td>11</td> <td>18</td> <td>13</td> <td>58.0645</td> <td>32</td> <td>33</td> <td>49.2308</td> <td>6</td> <td>3</td> <td>16</td> <td>20</td> <td>18</td> <td>52.6316</td> <td>0</td> <td>1</td> <td>7</td> <td>107</td> </tr> <tr class="w3-white"> <td>Noah Schleske</td> <td>9</td> <td>2</td> <td>2</td> <td>50</td> <td>3</td> <td>7</td> <td>30</td> <td>2</td> <td>0</td> <td>3</td> <td>3</td> <td>5</td> <td>37.5</td> <td>0</td> <td>0</td> <td>1</td> <td>9</td> </tr> <tr class="w3-gray"> <td>Jace Leabo</td> <td>11</td> <td>20</td> <td>23</td> <td>46.5116</td> <td>43</td> <td>41</td> <td>51.1905</td> <td>6</td> <td>4</td> <td>14</td> <td>32</td> <td>45</td> <td>41.5584</td> <td>2</td> <td>1</td> <td>4</td> <td>70</td> </tr> <tr class="w3-white"> <td>Wyatt Thorson</td> <td>9</td> <td>12</td> <td>22</td> <td>35.2941</td> <td>22</td> <td>46</td> <td>32.3529</td> <td>2</td> <td>4</td> <td>13</td> <td>7</td> <td>21</td> <td>25</td> <td>1</td> <td>1</td> <td>3</td> <td>53</td> </tr> <tr class="w3-gray"> <td>Nathan Stavas</td> <td>10</td> <td>2</td> <td>2</td> <td>50</td> <td>1</td> <td>3</td> <td>25</td> <td>0</td> <td>0</td> <td>1</td> <td>1</td> <td>3</td> <td>25</td> <td>0</td> <td>0</td> <td>2</td> <td>10</td> </tr> <tr class="w3-white"> <td>Ramon Lopez</td> <td>11</td> <td>17</td> <td>18</td> <td>48.5714</td> <td>34</td> <td>35</td> <td>49.2754</td> <td>5</td> <td>2</td> <td>3</td> <td>23</td> <td>23</td> <td>50</td> <td>0</td> <td>0</td> <td>10</td> <td>100</td> </tr> <tr class="w3-gray"> <td>Nick Haugen</td> <td>12</td> <td>19</td> <td>25</td> <td>43.1818</td> <td>27</td> <td>34</td> <td>44.2623</td> <td>2</td> <td>2</td> <td>10</td> <td>23</td> <td>16</td> <td>58.9744</td> <td>0</td> <td>1</td> <td>14</td> <td>95</td> </tr> <tr class="w3-white"> <td>RJ Ehlert</td> <td>11</td> <td>13</td> <td>11</td> <td>54.1667</td> <td>11</td> <td>5</td> <td>68.75</td> <td>0</td> <td>0</td> <td>5</td> <td>7</td> <td>6</td> <td>53.8462</td> <td>2</td> <td>0</td> <td>10</td> <td>81</td> </tr> <tr class="w3-gray"> <td>Ben Cole</td> <td>12</td> <td>0</td> <td>3</td> <td>0</td> <td>0</td> <td>5</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>1</td> <td>50</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> </tr> <tr class="w3-white"> <td>Michael Fielding</td> <td>11</td> <td>5</td> <td>14</td> <td>26.3158</td> <td>6</td> <td>21</td> <td>22.2222</td> <td>0</td> <td>0</td> <td>3</td> <td>7</td> <td>12</td> <td>36.8421</td> <td>0</td> <td>1</td> <td>0</td> <td>24</td> </tr> <tr class="w3-gray"> <td>Jacob Thompson</td> <td>12</td> <td>2</td> <td>5</td> <td>28.5714</td> <td>3</td> <td>9</td> <td>25</td> <td>3</td> <td>1</td> <td>1</td> <td>7</td> <td>2</td> <td>77.7778</td> <td>1</td> <td>0</td> <td>1</td> <td>16</td> </tr> <tr class="w3-white"> <td>Hunter Doll</td> <td>10</td> <td>6</td> <td>10</td> <td>37.5</td> <td>10</td> <td>17</td> <td>37.037</td> <td>2</td> <td>0</td> <td>6</td> <td>4</td> <td>11</td> <td>26.6667</td> <td>1</td> <td>0</td> <td>0</td> <td>21</td> </tr> <tr class="w3-gray"> <td>Christopher Kenyon</td> <td>12</td> <td>1</td> <td>2</td> <td>33.3333</td> <td>3</td> <td>3</td> <td>50</td> <td>0</td> <td>0</td> <td>2</td> <td>2</td> <td>3</td> <td>40</td> <td>1</td> <td>0</td> <td>1</td> <td>3</td> </tr> <tr class="w3-white"> <td>Jackson Boyum</td> <td>10</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>3</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>3</td> <td>25</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> </tr> <tr class="w3-gray"> <td>Matt Hendricks</td> <td>9</td> <td>4</td> <td>7</td> <td>36.3636</td> <td>10</td> <td>11</td> <td>47.619</td> <td>2</td> <td>0</td> <td>1</td> <td>3</td> <td>9</td> <td>25</td> <td>2</td> <td>0</td> <td>2</td> <td>21</td> </tr> <tr class="w3-white"> <td>Kevin Tierney</td> <td>11</td> <td>7</td> <td>15</td> <td>31.8182</td> <td>5</td> <td>24</td> <td>17.2414</td> <td>5</td> <td>0</td> <td>3</td> <td>7</td> <td>2</td> <td>77.7778</td> <td>0</td> <td>0</td> <td>1</td> <td>36</td> </tr> <tr class="w3-gray"> <td>Cian Buehler</td> <td>8</td> <td>3</td> <td>6</td> <td>33.3333</td> <td>3</td> <td>5</td> <td>37.5</td> <td>2</td> <td>0</td> <td>4</td> <td>2</td> <td>2</td> <td>50</td> <td>0</td> <td>0</td> <td>5</td> <td>15</td> </tr> <tr class="w3-white"> <td>Hayden Hart</td> <td>9</td> <td>12</td> <td>10</td> <td>54.5455</td> <td>16</td> <td>13</td> <td>55.1724</td> <td>2</td> <td>1</td> <td>5</td> <td>14</td> <td>13</td> <td>51.8519</td> <td>4</td> <td>1</td> <td>2</td> <td>48</td> </tr> <tr class="w3-gray"> <td>Reed Leabo</td> <td>8</td> <td>1</td> <td>2</td> <td>33.3333</td> <td>1</td> <td>5</td> <td>16.6667</td> <td>0</td> <td>1</td> <td>0</td> <td>1</td> <td>2</td> <td>33.3333</td> <td>0</td> <td>0</td> <td>0</td> <td>6</td> </tr> <tr class="w3-white"> <td>Daniel Ukkelberg</td> <td>12</td> <td>1</td> <td>0</td> <td>100</td> <td>0</td> <td>0</td> <td>100</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>6</td> </tr> </tbody> </table> </div> </body> </html> </body> Here is my javascript code //Sort Table Numerically function sortTable() { var table, rows, switching, i, x, y, shouldSwitch; table = document.getElementById("otcindividualstatsTable"); switching = true; /*Make a loop that will continue until no switching has been done:*/ while (switching) { //start by saying: no switching is done: switching = false; rows = table.rows; /*Loop through all table rows (except the first, which contains table headers):*/ for (i = 1; i < (rows.length - 1); i++) { //start by saying there should be no switching: shouldSwitch = false; /*Get the two elements you want to compare, one from current row and one from the next:*/ x = rows[i].getElementsByTagName("TD")[0]; y = rows[i + 1].getElementsByTagName("TD")[0]; //check if the two rows should switch place: if (Number(x.innerHTML) > Number(y.innerHTML)) { //if so, mark as a switch and break the loop: shouldSwitch = true; break; } } if (shouldSwitch) { /*If a switch has been marked, make the switch and mark that a switch has been done:*/ rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); switching = true; } } }
  5. ttnaddy16

    How to handle form variables that aren't used

    Thank you so much! Appreciate the help!
  6. My php code runs good but I don't want unchecked checkboxs to show up as undefined variables. Any ideas? Website Code- <!DOCTYPE html> <html> <body> <hr> <h2>Computer Repair Form</h2> </div> <div> <div> <form> <form action="submiiresults.php" method="post"> <div> <input type="text" name="firstname" placeholder="First Name" required/> </div> <div> <input type="text" name="lastname" placeholder="Last Name" required/> </div> <div> <input type="text" name="email" placeholder="Email" required/> </div> <div> <input type="text" name="subject" placeholder="Subject" required/> </div> <div> <div> <input type="checkbox" name="harddrivecrashed" value="Hard Drive Crashed"> <label>Hard Drive Crashed</label><br> <input type="checkbox" name="hasvirus" value="Has Virus"> <label>Has Virus</label><br> <input type="checkbox" name="needsoperatingsystem" value="Needs Operating System"> <label>Needs Operating System</label> <br><br> </div> <div> <input type="checkbox" name="needsmicrosoftoffice" value="Needs Microsoft Office"> <label>Needs Microsoft Office</label><br> <input type="checkbox" name="interestedinbackupservices" value="Interested In Backup Services"> <label>Interested In Backup Services</label><br> <input type="checkbox" name="wantsacustompcbuild" value="Wants A Custom PC Build"> <label>Wants A Custom PC Build</label> <br><br> <input type="submit" name="submit"> <input type="reset" value="Reset"> </form> <br><br> </div> </div> </form> </div> </body> </html> <!DOCTYPE html> <html> <body> <?php // Check if the form is submitted if ( isset( $_POST['submit'] ) ) { echo '<h2>Your Data Submitted!<h2/>'; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $subject = $_POST['subject']; $harddrivecrashed = $_POST['harddrivecrashed']; $hasvirus = $_POST['hasvirus']; $needsoperatingsystem = $_POST['needsoperatingsystem']; $needsmicrosoftoffice = $_POST['needsmicrosoftoffice']; $interestedinbackupservices = $_POST['interestedinbackupservices']; $wantsacustompcbuild = $_POST['wantsacustompcbuild']; // display the results //echo 'First Name:' . $firstname .' <br>Last Name:' . $lastname .' <br>Email Address:' .$email .' <br>Subject:' . $subject .' <br>Needs/Problems:<br>' . $harddrivecrashed .' <br>' . $hasvirus .' <br>' . $needsoperatingsystem .' <br>' . $needsmicrosoftoffice .' <br>' . $interestedinbackupservices .' <br>' . $wantsacustompcbuild; $formdata = fopen("formdata.txt", "a") or die("Unable to open file!"); $txt = "First Name:$firstname\r\n"; fwrite($formdata, $txt); $txt = "Last Name:$lastname\r\n"; fwrite($formdata, $txt); $txt = "Email Address:$email\r\n"; fwrite($formdata, $txt); $txt = "Subject:$subject\r\n"; fwrite($formdata, $txt); $txt = "Needs/Problems:$harddrivecrashed\r\n"; fwrite($formdata, $txt); $txt = "Needs/Problems:$hasvirus\r\n"; fwrite($formdata, $txt); $txt = "Needs/Problems:$needsoperatingsystem\r\n"; fwrite($formdata, $txt); $txt = "Needs/Problems:$needsmicrosoftoffice\r\n"; fwrite($formdata, $txt); $txt = "Needs/Problems:$interestedinbackupservices\r\n"; fwrite($formdata, $txt); $txt = "Needs/Problems:$wantsacustompcbuild\r\n"; fwrite($formdata, $txt); $txt = "\r\n"; fwrite($formdata, $txt); $txt = "\r\n"; fclose($formdata); exit; } ?> </body> </html>
  7. I tried phpmailer but i'm not sure where to include the phpmailer code can't i include it in submitresults.php that way it will include submitted from variables here's my new php code but it gives me an error now. I did include the vendor folder it references. <!DOCTYPE html> <html> <body> <?php // Check if the form is submitted if ( isset( $_POST['submit'] ) ) { // check if the post method is used to submit the form if ( filter_has_var( INPUT_POST, 'submit' ) ) { echo '<h2>Form data retrieved by using $_POST variable<h2/>'; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $subject = $_POST['subject']; $harddrivecrashed = $_POST['harddrivecrashed']; $hasvirus = $_POST['hasvirus']; $needsoperatingsystem = $_POST['needsoperatingsystem']; $needsmicrosoftoffice = $_POST['needsmicrosoftoffice']; $interestedinbackupservices = $_POST['interestedinbackupservices']; $wantsacustompcbuild = $_POST['wantsacustompcbuild']; // display the results echo 'First Name:' . $firstname .' <br>Last Name:' . $lastname .' <br>Email Address:' .$email .' <br>Subject:' . $subject .' <br>Needs/Problems:<br>' . $harddrivecrashed .' <br>' . $hasvirus .' <br>' . $needsoperatingsystem .' <br>' . $needsmicrosoftoffice .' <br>' . $interestedinbackupservices .' <br>' . $wantsacustompcbuild; /** * This example shows settings to use when sending via Google's Gmail servers. * This uses traditional id & password authentication - look at the gmail_xoauth.phps * example to see how to use XOAUTH2. * The IMAP section shows how to save this message to the 'Sent Mail' folder using IMAP commands. */ //Import PHPMailer classes into the global namespace use PHPMailer\PHPMailer\PHPMailer; require './vendor/autoload.php'; //Create a new PHPMailer instance $mail = new PHPMailer; //Tell PHPMailer to use SMTP $mail->isSMTP(); //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 0; //Set the hostname of the mail server $mail->Host = 'smtp.gmail.com'; // use // $mail->Host = gethostbyname('smtp.gmail.com'); // if your network does not support SMTP over IPv6 //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission $mail->Port = 587; //Set the encryption system to use - ssl (deprecated) or tls $mail->SMTPSecure = 'tls'; //Whether to use SMTP authentication $mail->SMTPAuth = true; //Username to use for SMTP authentication - use full email address for gmail $mail->Username = "ttnaddycomputerrepair@gmail.com"; //Password to use for SMTP authentication $mail->Password = "password"; //Set who the message is to be sent from $mail->setFrom('ttnaddycomputerrepair@gmail.com', 'Tyler'); //Set an alternative reply-to address $mail->addReplyTo('ttnaddycomputerrepair@gmail.com', 'Tyler'); //Set who the message is to be sent to $mail->addAddress('ttnaddycomputerrepair@gmail.com', 'Tyler'); //Set the subject line $mail->Subject = 'PHPMailer GMail SMTP test'; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $mail->msgHTML(file_get_contents('submitresults.php'), __DIR__); //Replace the plain text body with one created manually $mail->AltBody = 'This is a plain-text message body'; //send the message, check for errors if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; //Section 2: IMAP //Uncomment these to save your message in the 'Sent Mail' folder. #if (save_mail($mail)) { # echo "Message saved!"; #} } //Section 2: IMAP //IMAP commands requires the PHP IMAP Extension, found at: https://php.net/manual/en/imap.setup.php //Function to call which uses the PHP imap_*() functions to save messages: https://php.net/manual/en/book.imap.php //You can use imap_getmailboxes($imapStream, '/imap/ssl') to get a list of available folders or labels, this can //be useful if you are trying to get this working on a non-Gmail IMAP server. function save_mail($mail) { //You can change 'Sent Mail' to any other folder or tag $path = "{imap.gmail.com:993/imap/ssl}[Gmail]/Sent Mail"; //Tell your server to open an IMAP connection using the same username and password as you used for SMTP $imapStream = imap_open($path, $mail->Username, $mail->Password); $result = imap_append($imapStream, $path, $mail->getSentMIMEMessage()); imap_close($imapStream); return $result; exit; } ?> </body> </html>
  8. It was supposed to be submitresults.php but I change that after I posted it.
  9. I used the PHP mail to function and I keep getting this error Warning: mail(): SMTP server response: 553 We do not relay non-local mail, sorry. in C:\xampp\htdocs\submitresults.php on line 50 I believe this has to do with the from address I'm supposed to send this email from but I don't get what email I should use 'cause I'm technically not sending it from my only email account. <!DOCTYPE html> <html> <body> <?php // Check if the form is submitted if ( isset( $_POST['submit'] ) ) { // check if the post method is used to submit the form if ( filter_has_var( INPUT_POST, 'submit' ) ) { echo '<h2>Form data retrieved by using $_POST variable<h2/>'; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $subject = $_POST['subject']; $harddrivecrashed = $_POST['harddrivecrashed']; $hasvirus = $_POST['hasvirus']; $needsoperatingsystem = $_POST['needsoperatingsystem']; $needsmicrosoftoffice = $_POST['needsmicrosoftoffice']; $interestedinbackupservices = $_POST['interestedinbackupservices']; $wantsacustompcbuild = $_POST['wantsacustompcbuild']; // display the results echo 'First Name:' . $firstname .' <br>Last Name:' . $lastname .' <br>Email Address:' .$email .' <br>Subject:' . $subject .' <br>Needs/Problems:<br>' . $harddrivecrashed .' <br>' . $hasvirus .' <br>' . $needsoperatingsystem .' <br>' . $needsmicrosoftoffice .' <br>' . $interestedinbackupservices .' <br>' . $wantsacustompcbuild; $to = "ttnaddycomputerrepair@gmail.com"; $subject = "Tyler Naddy Computer Repair Form Submission"; $message = " <html> <head> <title>Tyler Naddy Computer Repair Form Submission</title> </head> <body> <?php echo 'First Name:' . $firstname .' <br>Last Name:' . $lastname .' <br>Email Address:' .$email .' <br>Subject:' . $subject .' <br>Needs/Problems:<br>' . $harddrivecrashed .' <br>' . $hasvirus .' <br>' . $needsoperatingsystem .' <br>' . $needsmicrosoftoffice .' <br>' . $interestedinbackupservices .' <br>' . $wantsacustompcbuild; ?> </body> </html> "; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; // More headers $headers .= 'From: <webmaster@example.com>' . "\r\n"; mail($to,$subject,$message,$headers); } exit; } ?> </body> </html>
  10. Yep you are right using localhost in the address bar instead of clicking the file worked 😀 I also got rid of their request variables because you're right I don't need them. Now if I wanted my PHP code to output this data to a text file and then keep adding to it for further form submissions how would I go about that? Basically, to this point, I've kinda learned about echos and variables for PHP coding but beyond that, I'm not really certain. The reason I would like it output to text files that I could check it every once in awhile and find out information from that file. Better yet is there a way that PHP code can send an automatic email to my email address so I can get constant updates of submissions?
  11. Yup you are right there were 3 echoes in total that did not have semicolons so I: after them, I added the 3 semicolons to the 3 echo statements but now when I submit my form code Nothing processes My PHP code is just shown It does not actually run and output any echos here's my modified PHP code- <!DOCTYPE html> <html> <body> <?php // Check if the form is submitted if ( isset( $_POST['submit'] ) ) { // retrieve the form data by using the element's name attributes value as key echo '<h2>form data retrieved by using the $_REQUEST variable<h2/>'; $firstname = $_REQUEST['firstname']; $lastname = $_REQUEST['lastname']; $email = $_REQUEST['email']; $subject = $_REQUEST['subject']; $harddrivecrashed = $_REQUEST['harddrivecrashed']; $hasvirus = $_REQUEST['hasvirus']; $needsoperatingsystem = $_REQUEST['needsoperatingsystem']; $needsmicrosoftoffice = $_REQUEST['needsmicrosoftoffice']; $interestedinbackupservices = $_REQUEST['interestedinbackupservices']; $wantsacustompcbuild = $_REQUEST['wantsacustompcbuild']; // display the results echo 'Form Data ' . $lastname .' ' . $firstname .' ' .$email .' ' . $subject .' ' . $harddrivecrashed .' ' . $hasvirus .' ' . $needsoperatingsystem .' ' . $needsmicrosoftoffice .' ' . $interestedinbackupservices .' ' . $wantsacustompcbuild; // check if the post method is used to submit the form if ( filter_has_var( INPUT_POST, 'submit' ) ) { echo '<h2>form data retrieved by using $_POST variable<h2/>'; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $subject = $_POST['subject']; $harddrivecrashed = $_POST['harddrivecrashed']; $hasvirus = $_POST['hasvirus']; $needsoperatingsystem = $_POST['needsoperatingsystem']; $needsmicrosoftoffice = $_POST['needsmicrosoftoffice']; $interestedinbackupservices = $_POST['interestedinbackupservices']; $wantsacustompcbuild = $_POST['wantsacustompcbuild']; // display the results echo 'Form Data ' . $lastname .' ' . $firstname .' ' .$email .' ' . $subject .' ' . $harddrivecrashed .' ' . $hasvirus .' ' . $needsoperatingsystem .' ' . $needsmicrosoftoffice .' ' . $interestedinbackupservices .' ' . $wantsacustompcbuild; } // check if the get method is used to submit the form if ( filter_has_var( INPUT_GET, 'submit' ) ) { echo '<h2>form data retrieved by using $_GET variable<h2/>'; $firstname = $_GET['firstname']; $lastname = $_GET['lastname']; $email = $_GET['email']; $subject = $_GET['subject']; $harddrivecrashed = $_GET['harddrivecrashed']; $hasvirus = $_GET['hasvirus']; $needsoperatingsystem = $_GET['needsoperatingsystem']; $needsmicrosoftoffice = $_GET['needsmicrosoftoffice']; $interestedinbackupservices = $_GET['interestedinbackupservices']; $wantsacustompcbuild = $_GET['wantsacustompcbuild']; } // display the results echo 'Form Data ' . $lastname .' ' . $firstname .' ' .$email .' ' . $subject .' ' . $harddrivecrashed .' ' . $hasvirus .' ' . $needsoperatingsystem .' ' . $needsmicrosoftoffice .' ' . $interestedinbackupservices .' ' . $wantsacustompcbuild; exit; } ?> </body> </html>
  12. Ha ha ha I do see that now can't believe I missed that so I did take out that form the top one and I took out the second form at the bottom 2 so now I only 2 form tags the opening and closing form tag. But now when I submit my form it gives me this error Parse error: syntax error, unexpected '$firstname' (T_VARIABLE), expecting ',' or ';' in C:\xampp\htdocs\submitresults.php on line 13, I really have no idea what this error is.
  13. On my website I have a form that uses the post method to submit data and my PHP code will not process the form submission. I am almost positive that my form code Is all correct but the PHP code I'm very unsure about. What I would like my PHP code to do Is process the form data and then possibly export that data to a text file so I can view the text file when I want to. If I could just get the PHP code to even process the data that would be great for starters. My PHP code right now just displays errors with variables.I know how to use Xampp So that's not the problem. Any help with this would be greatly appreciated. I would really like to try to get this problem solved soon because I would like to post my website soon. I do not have much experience in PHP coding and should be considered a beginner. Included will be my website code and my PHP code. Website Code- <!DOCTYPE html> <html> <body> <hr> <h2>Computer Repair Form</h2> </div> <div> <div> <form> <form action="submiiresults.php" method="post"> <div> <input type="text" name="firstname" placeholder="First Name" required/> </div> <div> <input type="text" name="lastname" placeholder="Last Name" required/> </div> <div> <input type="text" name="email" placeholder="Email" required/> </div> <div> <input type="text" name="subject" placeholder="Subject" required/> </div> <div> <div> <input type="checkbox" name="harddrivecrashed" value="Hard Drive Crashed"> <label>Hard Drive Crashed</label><br> <input type="checkbox" name="hasvirus" value="Has Virus"> <label>Has Virus</label><br> <input type="checkbox" name="needsoperatingsystem" value="Needs Operating System"> <label>Needs Operating System</label> <br><br> </div> <div> <input type="checkbox" name="needsmicrosoftoffice" value="Needs Microsoft Office"> <label>Needs Microsoft Office</label><br> <input type="checkbox" name="interestedinbackupservices" value="Interested In Backup Services"> <label>Interested In Backup Services</label><br> <input type="checkbox" name="wantsacustompcbuild" value="Wants A Custom PC Build"> <label>Wants A Custom PC Build</label> <br><br> <input type="submit" name="submit"> <input type="reset" value="Reset"> </form> <br><br> </div> </div> </form> </div> </body> </html> PHP Code- <!DOCTYPE html> <html> <body> <?php // Check if the form is submitted if ( isset( $_POST['submit'] ) ) { // retrieve the form data by using the element's name attributes value as key echo '<h2>form data retrieved by using the $_REQUEST variable<h2/>' $firstname = $_REQUEST['firstname']; $lastname = $_REQUEST['lastname']; $email = $_REQUEST['email']; $subject = $_REQUEST['subject']; $harddrivecrashed = $_REQUEST['harddrivecrashed']; $hasvirus = $_REQUEST['hasvirus']; $needsoperatingsystem = $_REQUEST['needsoperatingsystem']; $needsmicrosoftoffice = $_REQUEST['needsmicrosoftoffice']; $interestedinbackupservices = $_REQUEST['interestedinbackupservices']; $wantsacustompcbuild = $_REQUEST['wantsacustompcbuild']; // display the results echo 'Form Data ' . $lastname .' ' . $firstname .' ' .$email .' ' . $subject .' ' . $harddrivecrashed .' ' . $hasvirus .' ' . $needsoperatingsystem .' ' . $needsmicrosoftoffice .' ' . $interestedinbackupservices .' ' . $wantsacustompcbuild; // check if the post method is used to submit the form if ( filter_has_var( INPUT_POST, 'submit' ) ) { echo '<h2>form data retrieved by using $_POST variable<h2/>' $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $subject = $_POST['subject']; $harddrivecrashed = $_POST['harddrivecrashed']; $hasvirus = $_POST['hasvirus']; $needsoperatingsystem = $_POST['needsoperatingsystem']; $needsmicrosoftoffice = $_POST['needsmicrosoftoffice']; $interestedinbackupservices = $_POST['interestedinbackupservices']; $wantsacustompcbuild = $_POST['wantsacustompcbuild']; // display the results echo 'Form Data ' . $lastname .' ' . $firstname .' ' .$email .' ' . $subject .' ' . $harddrivecrashed .' ' . $hasvirus .' ' . $needsoperatingsystem .' ' . $needsmicrosoftoffice .' ' . $interestedinbackupservices .' ' . $wantsacustompcbuild; } // check if the get method is used to submit the form if ( filter_has_var( INPUT_GET, 'submit' ) ) { echo '<h2>form data retrieved by using $_GET variable<h2/>' $firstname = $_GET['firstname']; $lastname = $_GET['lastname']; $email = $_GET['email']; $subject = $_GET['subject']; $harddrivecrashed = $_GET['harddrivecrashed']; $hasvirus = $_GET['hasvirus']; $needsoperatingsystem = $_GET['needsoperatingsystem']; $needsmicrosoftoffice = $_GET['needsmicrosoftoffice']; $interestedinbackupservices = $_GET['interestedinbackupservices']; $wantsacustompcbuild = $_GET['wantsacustompcbuild']; } // display the results echo 'Form Data ' . $lastname .' ' . $firstname .' ' .$email .' ' . $subject .' ' . $harddrivecrashed .' ' . $hasvirus .' ' . $needsoperatingsystem .' ' . $needsmicrosoftoffice .' ' . $interestedinbackupservices .' ' . $wantsacustompcbuild; exit; } ?> </body> </html>
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.