using javascript slider with php array -
i'm attempting make range slider work php. have part of code can't range slider update number. can see is somewhere in onchange event. posted sections of code need attention. 1 big if else statement , javascript @ end. why did way don't know. i'm in bit of time crunch though. solution awesome.
// view products else { // display site links echo "<p> <a href='./index.php'>sweetshop</a></p>"; echo "<h3>our products</h3>"; echo "<form name='form1' method='post' action=''> <p> <input id='slider' type='range' min='.50' max='2.00' step='.50' value='2.00' onchange='printvalue('slider','rangevalue')' /> <input style='text-align: center' id='rangevalue' type='text' size='2' /> </p> </form>"; echo "<table align='center' border='2px solid' style='width:500px;' cellspacing='0'>"; echo "<tr> <th style='border-bottom:1px solid #000000;'>name</th> <th style='border-bottom:1px solid #000000;'>price</th> <th style='border-bottom:1px solid #000000;'>category</th> </tr>"; // loop display products foreach($products $id => $product) { echo "<tr> <td style='border-bottom:1px solid #000000;'><a href='./index.php?view_product=$id'>" . $product['name'] . "</a></td> <td style='border-bottom:1px solid #000000;'>$" . $product['price'] . "</td> <td style='border-bottom:1px solid #000000;'>" . $product['category'] . "</td> </tr>"; } echo "</table>"; } echo $footer; ?> <script> function printvalue(sliderid, textbox){ var x= document.getelementbyid(textbox); var y= document.getelementbyid(sliderid); x.value = y.value; } window.onload = function () { printvalue('slider', 'rangevalue') } </script>
not sure if counts solution, i'd take @ onchange code:
onchange='printvalue('slider','rangevalue')'
the quotation marks inside 'onchange' attribute not escaped. i'd suggest changing to:
onchange="printvalue('slider','rangevalue')"
not being able test code, don't know if fix problem, should move things forwards @ least!
Comments
Post a Comment