php - How to change timeout in javascript dynamically -


good morning everyone!

i've got question, not sure language should using. i'm assuming javascript since slideshow javascript.

i need create slideshow user can change time in between slides. there 100 slides , want able set timing in between each individually.

i've put pics on server , created db links them , slideshow works fine, except can't seem figure out way make timeout have different values. appreciated.

here's code:

<?php include_once 'includes/db_connect.php'; ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>weather show</title> <meta name="viewport" content="width=device-width,initial-scale=1"> <link rel="stylesheet" href="responsiveslides.css"> <link rel="stylesheet" href="demo.css"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="responsiveslides.min.js"></script>  <script type="text/javascript"> function display_c(){      var refresh=1000; // refresh rate in milli seconds      mytime=settimeout('display_ct()',refresh) }  function display_ct() {      var strcount      var x = new date()      document.getelementbyid('ct').innerhtml = x;      tt=display_c(); } </script>   <?php echo "<script>                 $(function () {                     $('#slider1').responsiveslides({                         maxwidth: 1080,                         speed: 1000,                         timeout: 5000                         });                     });               </script>";  echo "</head> <body style='background-color: #000;' onload=display_ct();> <div id='wrapper'>";    $result = mysqli_query($mysqli,"select * weather status = '1'"); ?>  <!-- slideshow 1 --> <ul class="rslides" id="slider1"> <?php  while($row = mysqli_fetch_array($result))     {         echo "<li><img src='"; echo $row['link']; echo "' alt='"; echo $row['link']; echo "'></li>";     }     ?> </ul> </div><!-- end wrapper -->  <div style=" margin-top:-30px; "> <span id='ct' style="font-weight:bold; font-size:36px; color:#fff; margin-left:30px;"></span> </div>   </body> </html> 

i going use php variables time, that's why i'm echo(ing) javascript. did not work me. if knows how , wants let me know, amazing! thank you!

you can of @ javascript side if put refresh , mytime variable more global. keep track of mytime-variable (from display_c()). add edit box , whatever event need track new interval specified.

as event triggered call cleartimeout(mytime); stop time, update refresh variable new value , call display_c() again start process anew:

<?php    $refresh = 1000; // current value database    echo <<<javavscript     <script>     $(function () {          $('#slider1').responsiveslides({             maxwidth: 1080,             speed: $refresh,             timeout: 5000          });     });      $('#speed-input-id').change(function(e) {         refresh = parseint($(this).val());         $.ajax('/updatethedatbasetimeoutvalueurl', {data: {refresh: refresh}});         // can't on reconfiguring plugin, little information         updatetheresponsiveslidestimeout(refresh);          e.preventdefault();     });  }); 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -