yandoo Posted January 8, 2007 Share Posted January 8, 2007 Hi all,i was hoping for some technical help using php and mysql.I have a simple database connected (mysql) and website (php/html).A form of this website involves me inputting a date field in it. i have created a date function using the following javascript code:var todaysdate = new Date();year = todaysdate.getFullYear();month = todaysdate.getMonth();date = todaysdate.getDate();day = todaysdate.getDay();var monthname = new Array("01","02","03","04","05","06","07","08","09","10","11","12");var dayname = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");The date is inserted into the webpage using the following code:<script language="JavaScript" type="text/javascript">document.writeln(year+"-"+monthname[month]+"-"+date);</script>.Basically i want to be able to insert this javascript date (by default) into the date field of my form, using the php echo method, if it is possible????Example:<?php echo <script language="JavaScript" type="text/javascript">document.writeln(year+"-"+monthname[month]+"-"+date);</script> ?>Please help as this is doing my head in!!!!!Thank Youtom Link to comment https://forums.phpfreaks.com/topic/33345-insert-java-script-date-into-php-echo-statement/ Share on other sites More sharing options...
Cep Posted January 8, 2007 Share Posted January 8, 2007 Its not possible to create something in Client side script and have Server side script return the value without first sending data to the server for the server side script to process it.If there is an event trigger in Javascript similar to OnLoad, or OnOpen in VBA you might be able to set the default value of that HTML control to the date worked out by your script above when the user first opens the webpage, in this case you do not need PHP at all. Link to comment https://forums.phpfreaks.com/topic/33345-insert-java-script-date-into-php-echo-statement/#findComment-155827 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.