I have this variables in file javascript: // when number 10 is changed in database with another number... number 10 must change and here ( column is: repeat_sec ) var repSec = 10; // when number 30 is changed in database with another number... number 30 must change and here ( column is: duration_Ad ) var duAd = 30; // when number 8 is changed in database with another number... number 8 must change and here ( column is: close_Button ) var closeButt = 8; how this change value when is changed in database ? Can someone help me?
What type of database? What server side language are you accessing the database with? How are you passing values TO the database. Do you need this realtime async, or just on page loads? Instead of hard declaring those values in your script, or worse dynamically loading / building the script, you should probably be pulling those values with AJAX using something like JSON. If you need 'realtime' updates that could involve getting into setting up websockets, or if you don't need it 100% instant you could use the more predictable "polling" method. Really you haven't told us enough to provide you an answer.
One way to find out is to declare global variable and see if it worked. Something like this: <script> var repSec , duAd , closeButt; repSec = "<?php echo $repSec; ?>"; duAd = "<?php echo $duAd; ?>"; closeButt = "<?php echo $closeButt; ?>"; </script> Code (markup): Put it above a link to your JS files, make sure you don't declare local variable again in the JS file. And don't use async, it would load and execute JavaScript before your website finished loading PHP variables. I'm not sure if async attribute compatible with W3C standard.