Tag Archives: javascript

javascript clock with server time [duplicate]

Questions: Possible Duplicate: Making Live Clock javascript I want to create a clock, with javascript and php. It should start from a server time (unix timestamp with php) and continue with javascript. How can I create it? In this topic, he said to use Date.now();, but this function return a timestamp with milliseconds, and php… Read More »

Execute Google Chart API (Javascript) in php file

Questions: I am creating a mail in php, in a wordpress plugin, and would like to include an image created by the google chart api. I tried the following: <?php $message.= <<<HTML <script> google.charts.load(‘current’, { ‘packages’: [‘corechart’] }); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ [‘Year’, ‘Sales’, ‘Expenses’], [‘2013’, 1000, 400], [‘2014’, 1170, 460],… Read More »

how to assign javascript variable value to php variable

Questions: I have declared a javascript variable , var myJavascriptVar = 12345; And unable to assign that value to php variable; $myPhpVar = ‘myJavascriptVar’; I know Ajax may be the solution of my problem. But i don’t know how to use Ajax and solve the problem. <html> <body> <script> var myJavascriptVar = 12345; <?php $myPhpVar=’myJavascriptVar’;?>… Read More »

Set JavaScript variable from PHP

Questions: How I can set the JavaScript variable strUser from PHP? I am using the following code: <script> function val() { var e = document.getElementById(“ali”); var strUser = e.options[e.selectedIndex].text; } </script> brand<select id=”ali” onChange=”val()”> <?php $brand=modsearchkhodroHelper::retrieve(); foreach($brand as $item) { ?> <option value=”<?php echo $item[‘brand’]?>” selected=”<?php $id=$item[‘brand’]?>”> <?php echo $item[‘brand’]?> </option> <?php } echo “</select>”;… Read More »

Pass JSON from php to javascript

Questions: I want to localize my webapp. Since localization through javascript only is not recommended I thought using php would be an alternative. So with php I read a messages.json file that stores all localization data. $json = file_get_contents(“_locales/en/messages.json”); In the header of my webapp I generate some javascript with php according to the user’s… Read More »

Javascript/PHP and timezones

Questions: I’d like to be able to guess the user’s timezone offset and whether or not daylight savings is being applied. Currently, the most definitive code that I’ve found for this is here: http://www.michaelapproved.com/articles/daylight-saving-time-dst-detect/ So this gives me the offset along with the DST indicator. Now, I want to use these in my PHP scripts… Read More »