Jump to content

php interact with javascript


marcus_epik

Recommended Posts

Hi,

 

so i want to make java script get the client date and then pass it on to php so that it can upload it to the database but i have no idea how to go about doing this and was wondering if any of you could help or give me an idea about how to go about doing this.

 

Thanks,

          Marcus

Link to comment
https://forums.phpfreaks.com/topic/265875-php-interact-with-javascript/
Share on other sites

There are several useful methods in JavaScript?s Date object (e.g. Date.getTimezoneOffset(), Date.toLocaleString())

 

You would then have to save teh information retreaved to the db.

 

ok,

 

that is a good start, would anybody have any idea how to get the date into a php variable

 

thanks,

          Marcus

  • 3 weeks later...

marcus_epik,

 

    I would use jQuery AJAX, but here is a "Quick and Dirty" that should work...

 

Scot L. Diddle, Richmond VA

 



	<script>

		parmPassedToPHP = new Image();

		function getUsersScreenResolution(incomingVar) {

			var passedParm = incomingVar;

			// alert('Hi Mom');

			var result;

			var at      = '@';
			var tilde   = '~';
			var param1A = screen.width;
			var param1B = 'W';
			var param2A = screen.height;
			var param2B = 'H';
			var phpVariable = param1A + at +  param1B + tilde + param2A + at +  param2B;

			iURL="transferJSParamToPHP.php?variable=" + phpVariable;

			result = parmPassedToPHP.src=iURL;

			// alert(result);

		};

	</script>

 

Where : transferJSParamToPHP.php

 

looks like this...

 

 

<?php

$getVariable = $_GET['variable'];

// Copy $getVariable to DB...


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.