Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: [php/js/html]Data w textarea
Forum PHP.pl > Forum > Przedszkole
kamil9091
  1. <head>
  2.  
  3. <script language="javascript">
  4. <!-- W3e JAVAScript Preset/Date
  5. var DDMMYY =0
  6. var MMDDYY =1
  7.  
  8. function getdate(mode)
  9. {
  10. var now = new Date();
  11. var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
  12. if (mode==DDMMYY)
  13. var MonthDayYear =(dayNr+". "+(now.getMonth()+1)+". "+now.getYear());
  14. else
  15. var MonthDayYear =((now.getMonth()+1)+" . "+dayNr+" . "+now.getYear());
  16.  
  17. return MonthDayYear;
  18. }
  19.  
  20. function gettime()
  21. {
  22. var now = new Date();
  23. var ampm = (now.getHours() >= 12) ? " P.M." : " A.M."
  24. var hours = now.getHours();
  25. hours = ((hours > 12) ? hours - 12 : hours);
  26.  
  27. var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
  28. var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
  29. var TimeValue =(" " + hours + minutes + seconds + " " + ampm);
  30.  
  31. return TimeValue;
  32. }//-->
  33. </script>
  34.  
  35. </head>
  36.  
  37. <?php
  38.  
  39. $data = <script language=javascript>
  40. document.write(getdate(DDMMYY));
  41. </script>;
  42.  
  43. echo "<textarea>$data</textarea>"
  44. ?>


ok - wszystko pieknie wyglada - ale czemu w efekcie pole textarea jest puste ?
Cysiaczek
Jak dodasz apostrofy do:
  1. <?php
  2. $data = <script language=javascript>
  3. document.write(getdate(DDMMYY));
  4. </script>;
  5. ?>


To tak jakby pole textarea bêdzie wygl±da³o tak: klik

Nie wiem tylko, czy efekt Ciê satysfakcjonuje tongue.gif

Pozdrawiam.
nospor
  1.  
  2. <script language="javascript">
  3. <!-- W3e JAVAScript Preset/Date
  4. var DDMMYY =0
  5. var MMDDYY =1
  6.  
  7. function getdate(mode)
  8. {
  9. var now = new Date();
  10. var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
  11. if (mode==DDMMYY)
  12. var MonthDayYear =(dayNr+". "+(now.getMonth()+1)+". "+now.getYear());
  13. else
  14. var MonthDayYear =((now.getMonth()+1)+" . "+dayNr+" . "+now.getYear());
  15.  
  16. return MonthDayYear;
  17. }
  18.  
  19. function gettime()
  20. {
  21. var now = new Date();
  22. var ampm = (now.getHours() >= 12) ? " P.M." : " A.M."
  23. var hours = now.getHours();
  24. hours = ((hours > 12) ? hours - 12 : hours);
  25.  
  26. var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
  27. var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
  28. var TimeValue =(" " + hours + minutes + seconds + " " + ampm);
  29.  
  30. return TimeValue;
  31. }//-->
  32.  
  33. </head>
  34. <?php
  35.  
  36. echo '<textarea id="test"></textarea>';
  37. ?>
  38. <script language=javascript>
  39. document.getElementById('test').value = getdate(DDMMYY);
  40.  
  41. </body>
  42. </html>


ps: rok ci sie źle wylicza
kamil9091
@nospor - ale jak chce w tym polu textarea dodac jeszcze cos innego poza data

bo nic sie eni pojawia jak tam dodam
nospor
Kod
<?php

echo '<textarea id="test">cos innego</textarea>';
?>
<script language=javascript>
document.getElementById('test').value += getdate(DDMMYY);
</script>

smile.gif

A nie mozesz tej daty w php wyslac?
  1. <?php
  2. echo '<textarea id="test">cos innego '.date('Y-m-d').'</textarea>';
  3. ?>
kamil9091
Cytat(nospor @ 11.05.2007, 08:44:58 ) *
Kod
<?php

echo '<textarea id="test">cos innego</textarea>';
?>
<script language=javascript>
document.getElementById('test').value += getdate(DDMMYY);
</script>

smile.gif


ale wlasnie tak nei dziala
Cytat(nospor @ 11.05.2007, 08:44:58 ) *
A nie mozesz tej daty w php wyslac?
  1. <?php
  2. echo '<textarea id="test">cos innego '.date('Y-m-d').'</textarea>';
  3. ?>



w sumie to moge....

tak tez moze byc

dziki za pomoc
To jest wersja lo-fi g³ównej zawarto¶ci. Aby zobaczyæ pe³n± wersjê z wiêksz± zawarto¶ci±, obrazkami i formatowaniem proszê kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.