0

I use timepicker and the jquery permit to select the hour and minute interval we want. I would like to have different minute interval depends on the data in my database. For example if the database number is 5 I want to have

   minutes: {
      starts: 0, // first displayed minute
      ends: 55,  // last displayed minute
     interval: 5 // interval of displayed minutes
   },

and if it's 15 I would like to have

   minutes: {
      starts: 0, // first displayed minute
      ends: 45,  // last displayed minute
     interval: 15 // interval of displayed minutes
   },

I'm not sure if it's possible to do this since I don't know a lot about jquery. After I'm using php.

does anyone have an idea? Thanks

1 Answer 1

1

You could simply output an js variable with php

<script type="text/javascript">
    var interval_from_database = <?php echo($interval); ?>;
</script>

where $interval is your php variable with the interval value you got from the database. And then you can just do it like this:

minutes: {
  starts: 0, // first displayed minute
  ends: 45,  // last displayed minute
 interval: interval_from_database // interval of displayed minutes
},
Sign up to request clarification or add additional context in comments.

4 Comments

thanks I try it. if the interval is 10, instead of put 00, 10, 20... it will put 00, 010 and nothing else do i need to change something else?
Please have a look at the source code of your php page in your browser. Which value is assigned to the js variable interval_from_database?
the value assigned is: var interval_from_database = '10';
Oh, sorry, my mistake, please remove ' in the js variable code: var interval_from_database = <?php echo($interval); ?>; It must not be a string. Answer edited. Does it work now?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.