Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate an HTML5 range "slider" that does the same as the following drop down menu
    primarykey
    data
    text
    <p>I have a drop down menu, which is filled from a database. When I select a value in the menu it displays a table of the data selected from the database. I'd like to change this to an HTML5 range slider. So far with no luck. I also want to show the values (dates) beside the range as I move along it. This is the code to the drop down menu:</p> <pre><code>// Set SQL string $query = "SELECT * FROM Test"; // Execute SQL $result = mysql_query($query); // Find number of rows in the resulting recordset array $num = mysql_numrows($result); // Initialise loop counter $i = 0; echo ("&lt;form&gt;&lt;select name='users' onchange='showUser(this.value)'&gt;"); // Loop through recordset until end while ($i &lt; $num) { // Associate variables for result at position i at table location specified $Time = mysql_result($result, $i, "Time"); // Echo each entry as an OPTION for the Select List echo ("&lt;option value=\"$Time\"&gt;$Time&lt;/option&gt;"); // Increment Loop Counter $i++; } echo ("&lt;/select&gt;&lt;/form&gt;&lt;br&gt;"); </code></pre> <p>gettime.php:</p> <pre><code>$sql = "SELECT * FROM Test WHERE Time = '" . $q . "'"; $resultb = mysql_query($sql); if (!$resultb) { echo "&lt;p&gt;The following SQL failed&lt;/p&gt;&lt;p&gt;" . $sql . "&lt;/p&gt;"; } echo "&lt;table border='1'&gt; &lt;tr&gt; &lt;th&gt;Time&lt;/th&gt;&lt;th&gt;First PC Room&lt;/th&gt; &lt;th&gt;First Group Study Room 1&lt;/th&gt; &lt;th&gt;First Group Study Room 2&lt;/th&gt; &lt;th&gt;First Main Room&lt;/th&gt; &lt;/tr&gt;"; while ($rowb = mysql_fetch_array($resultb)) { $bmsTime = $rowb['Time']; //Convert Excel Timestamp of DB to Unix Timestamp $unixtime=($bmsTime-25569)*86400; $readable=date('l jS \of F Y h:i:s A',($unixtime)); echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $readable . "&lt;/td&gt;"; echo "&lt;td&gt;" . $rowb['firstPCroom'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $rowb['firstGrpStdyRm1'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $rowb['firstGrpStdyRm2'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $rowb['firstmainroom'] . "&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; </code></pre> <p>Below is what I have so far on the "slider":</p> <pre><code>echo "&lt;input id='slider' type='range' min='0' max=\"$num\" step='any' /&gt; &lt;span id='range'&gt; &lt;/span&gt;"; ?&gt; &lt;script&gt; var selectmenu=document.getElementById("slider"); var colorchange; selectmenu.onchange=function changecolour(){ if (selectmenu.value&lt;"0.5") {colorchange=0} else if (selectmenu.value&gt;="0.5") {colorchange=Math.round(selectmenu.value)} document.getElementById("range").innerHTML=colorchange; } &lt;/script&gt; </code></pre> <p>Any help would be greatly appreciated! Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload