Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Ukrywanie daty
kemes123
post
Post #1





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 15.04.2010

Ostrzeżenie: (0%)
-----


Znalazłem skrypt podający aktualną godzinę co do sekundy.
  1.  
  2. <form method="POST" id="Formularz_zegarka" action="wstaw_rekord.php" target="_top">
  3. <input type="text" name="date2" size="19">
  4. <script TYPE="text/javascript">
  5. function zero(element) {
  6. if (element < 10) return element = "0" + element;
  7. return element;
  8. }
  9. function pokaz_czas() {
  10. var czas=new Date();
  11. var date2 = czas.getFullYear()+"-"+zero((czas.getMonth()+1))+"-"+zero(czas.getDate())+" "+zero(czas.getHours())+":"+zero(czas.getMinutes())+":"+zero(czas.getSeconds());
  12. var forma = document.getElementById('Formularz_zegarka');
  13. var czas_na_zegarku = zero(czas.getHours())+":"+zero(czas.getMinutes())+":"+zero(czas.getSeconds());
  14. forma.date2.value=date2;
  15. setTimeout("pokaz_czas()",1000)
  16. }
  17.  
  18. pokaz_czas();
  19. </script>

Zegarek jest częścią formularza data pobierana jest z pola i przekazywana do bazy.
Jeżeli chcę zmienić type na hidden
  1. <input type="hidden" name="date2" size="19">

Pole znika ale dane do bazy już nie są przekazywane.
W formularzu mam kilka innych pól tekstowych, które są ukryte i z nimi nie ma problemu.
Może ktoś z Was będzie wiedział o co chodzi

dodatkowo jeżeli zmienie lokalizację
  1. <input type="text" name="date2" size="19">

gdzieś niżj w kodzie zegarek się ni wyświetla

Ten post edytował kemes123 2.03.2011, 19:29:00
Go to the top of the page
+Quote Post
d3ut3r
post
Post #2





Grupa: Zarejestrowani
Postów: 709
Pomógł: 176
Dołączył: 24.10.2010

Ostrzeżenie: (0%)
-----


a nie lepiej w samym php dodawać datę do zapytania ?


--------------------
http://d3ut3r.wordpress.com/ | mysql_* jest przestarzałe UŻYWAJ PDO!
Go to the top of the page
+Quote Post
kemes123
post
Post #3





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 15.04.2010

Ostrzeżenie: (0%)
-----


I tu się pojawia problem data musi być odświeżana cały czas. Już miałem wpisywany czas w pole ale godzina odświeżała się dopiero po przeładowaniu strony.
Go to the top of the page
+Quote Post
kokers
post
Post #4





Grupa: Zarejestrowani
Postów: 154
Pomógł: 33
Dołączył: 18.10.2010
Skąd: Katowice

Ostrzeżenie: (0%)
-----


nadaj id temu inputowi i zmień forma.date2.value=date2 na odwołanie bezpośrednio do id czyli:


  1. <input type="hidden" name="date2" size="19" id="date2" />
  2.  
  3. <script TYPE="text/javascript">
  4. function zero(element) {
  5. if (element < 10) return element = "0" + element;
  6. return element;
  7. }
  8. function pokaz_czas() {
  9. var czas=new Date();
  10. var date2 = czas.getFullYear()+"-"+zero((czas.getMonth()+1))+"-"+zero(czas.getDate())+" "+zero(czas.getHours())+":"+zero(czas.getMinutes())+":"+zero(czas.getSeconds());
  11. var czas_na_zegarku = zero(czas.getHours())+":"+zero(czas.getMinutes())+":"+zero(czas.getSeconds());
  12. document.getElementById('date2').value=date2;
  13. setTimeout("pokaz_czas()",1000)
  14. }
  15.  
  16. pokaz_czas();
  17. </script>


Ten post edytował kokers 2.03.2011, 19:47:52


--------------------
‎"Sometimes you're gonna get odd error syntax, unexpected T_PAAMAYIM_NEKUDOTAYIM and you're like, what in the world is that thing i have no idea what went wrong in my code. In english that error means you screwed up the references to an object" Kevin Skoglund
Drobna prywata: Ależ nie nie, nie zamierzam zmieniać płci w najbliższym czasie, więc zwracanie się do mnie per Pan jest odrobinkę nietrafione.
Go to the top of the page
+Quote Post
kemes123
post
Post #5





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 15.04.2010

Ostrzeżenie: (0%)
-----


Nadal po ustawieniu atrybutu hidden nie pobiera danych po dopisanu disabled tak aby data została w tym polu też jest to samo

Ten post edytował kemes123 2.03.2011, 20:12:53
Go to the top of the page
+Quote Post
kokers
post
Post #6





Grupa: Zarejestrowani
Postów: 154
Pomógł: 33
Dołączył: 18.10.2010
Skąd: Katowice

Ostrzeżenie: (0%)
-----


disabled powoduje że dany input(select i inne) stają się nieaktywne i ich wartości nie są nigdzie przesyłane.

to działa na pewno

  1. <script TYPE="text/javascript">
  2. window.onload=function(){
  3. pokaz_czas();
  4. }
  5. function zero(element) {
  6. if (element < 10) return element = "0" + element;
  7. return element;
  8. }
  9. function pokaz_czas() {
  10. var czas=new Date();
  11. var date2 = czas.getFullYear()+"-"+zero((czas.getMonth()+1))+"-"+zero(czas.getDate())+" "+zero(czas.getHours())+":"+zero(czas.getMinutes())+":"+zero(czas.getSeconds());
  12. var czas_na_zegarku = zero(czas.getHours())+":"+zero(czas.getMinutes())+":"+zero(czas.getSeconds());
  13. document.getElementById('date2').value=date2;
  14. setTimeout("pokaz_czas()",1000)
  15. }
  16.  
  17.  
  18. </script>
  19.  
  20. <form method="POST" id="formularz_zegarka" action="wstaw_rekord.php" target="_top">
  21. <input type="hidden" name="date2" size="19" id="date2" value="echo"/>
  22. <input type="submit" value="send" />
  23. </form>



lub po prostu można ewentualnie zrobić stylami :o)
  1. <input type="hidden" name="date2" size="19" id="date2" style="display:none;"/>


Ten post edytował kokers 2.03.2011, 20:24:16


--------------------
‎"Sometimes you're gonna get odd error syntax, unexpected T_PAAMAYIM_NEKUDOTAYIM and you're like, what in the world is that thing i have no idea what went wrong in my code. In english that error means you screwed up the references to an object" Kevin Skoglund
Drobna prywata: Ależ nie nie, nie zamierzam zmieniać płci w najbliższym czasie, więc zwracanie się do mnie per Pan jest odrobinkę nietrafione.
Go to the top of the page
+Quote Post
kemes123
post
Post #7





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 15.04.2010

Ostrzeżenie: (0%)
-----


Dzięki wielkie działa
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 03:37