Why does this not work, but is ok for "Y-m-d"?
<?php
echo "<input id=mindate value=$mindate>
<input type=button value=Today
onclick='javascript:document.getElementById(\'mindate\').value
=\'".date("Y-m-d H:i:s")."\';'>";
?>
On the page it looks like:
<input type=button value=Today
onclick='javascript:document.getElementById(\'mindate\').value
=\'2011-01-07 19:37:21\';'>
Must have something to开发者_C百科 do with all those quotes, but can't see where...
Use double quotes for your HTML attributes.
<?php
echo '<input id="mindate" value="$mindate">
<input type="button" value="Today"
onclick="javascript:document.getElementById(\'mindate\').value
=\'' . date("Y-m-d H:i:s") . '\';">';
?>
You need to use double quotes for mindate etc.. Try this:
<?php echo "<input id=mindate value=$mindate> <input type=button value=Today
onclick='javascript:document.getElementById(\"mindate\").value
=\"".date("Y-m-d H:i:s")."\";'>";
?>
精彩评论