Jump to content

PHP/Javascript problem


X9183

Recommended Posts

HELP !!!! - My PHP script uses a PHP INCLUDE which brings in a JAVASCRIPT that is working fine. My problem is I cannot convert the JAVASCRIPT variables to PHP.  I also use SESSIONS in place of COOKIES. IF anybody knows of a simple solution and if possible with a few coding examples I'd be most grateful???

Link to comment
Share on other sites

  • 3 weeks later...

Sorry it has taken a while.  As you see everything is in order until I get to the "form method= " and there I just do not know where to go it more accurate to confess that I am confused. Any sample code showing the link between Client and Server, explaining it to a kindergarten student would be gratefully appreciated.

 

<?PHP SESSION_START(); ob_start();

$self    = $_SERVER['PHP_SELF'];

$referer  = $_SERVER['HTTP_REFERER']; ?>

<html><head><title>time test</title>

<script language="JavaScript" type="text/javascript">

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function displaydate()

{

var date = new Date();

var d  = date.getDate();

var day = (d < 10) ? '0' + d : d;

var m = date.getMonth() + 1;

var month = (m < 10) ? '0' + m : m;

var yy = date.getYear();

var year = (yy < 1000) ? yy + 1900 : yy;

var hours = date.getHours();

var minutes = date.getMinutes();

var seconds = date.getSeconds();

    if (minutes < 10) minutes = "0" + minutes;

    if (seconds < 10) seconds = "0" + seconds;

var datum =

    (year + "/" + month + "/" + day +

    ' - '+hours+':'+minutes+':'+seconds);

    document.displaydate.clientdate.value=datum; }

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function writedate()

{

var date = new Date();

var d  = date.getDate();

var day = (d < 10) ? '0' + d : d;

var m = date.getMonth() + 1;

var month = (m < 10) ? '0' + m : m;

var yy = date.getYear();

var year = (yy < 1000) ? yy + 1900 : yy;

var hours = date.getHours();

var minutes = date.getMinutes();

var seconds = date.getSeconds();

    if (minutes < 10) minutes = "0" + minutes;

    if (seconds < 10) seconds = "0" + seconds;

var yyyymmdd = (year + "-" + month + "-" + day +

    ' ~ '+hours+':'+minutes+':'+seconds);

    document.writedate.klientdate.value=yyyymmdd; }

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

</script></head>

<body>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<form method="post" action="" name="displaydate">

Display Date:

<input type="text"  name="clientdate" value="" size=21></form>

<script>displaydate()</script>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<form method="post" action="" name="writedate">

<input type="hidden"  name="klientdate" value="" size=21></form>

<script>writedate()</script>

</body></html>  :'(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.