Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [inne][HTML]Jak zlikwidować kursor z formularza?, Kursor w formularzy w którym jest dynamiczny czas!
kubakuba
post
Post #1





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 18.01.2011

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


Witam.

Wstawiłem do strony kod zegarka. Zegar wyświetla mi się w formularzu.
Problem polega na tym, że jak kliknę na niego, na końcu pojawia się kursor co jest zrozumiałe aczkolwiek denerwujące.
Chciałbym się zapytać czy istnieje możliwość zablokowania pojawiania się kursora w tym miejscu?
Go to the top of the page
+Quote Post
sada
post
Post #2





Grupa: Zarejestrowani
Postów: 302
Pomógł: 24
Dołączył: 6.12.2008

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


Zdefiniować własny kursor "zerowy" i zmieniać na niego onmouseover="....."

Ten post edytował sada 12.02.2011, 15:23:01
Go to the top of the page
+Quote Post
gargamel
post
Post #3





Grupa: Zarejestrowani
Postów: 278
Pomógł: 35
Dołączył: 25.06.2010

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


Jeśli wyświetlasz zegarek w polu input to najlepiej z tego zrezygnować (bo nie do tego input służy) i wyświetlać w divie. Jeśli zależy Ci na inpucie to spróbuj mu dać disabled='disabled' albo readonly='readonly'.

Pokaż kod jakiego używasz
Go to the top of the page
+Quote Post
kubakuba
post
Post #4





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 18.01.2011

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


Oto kod w jS

  1. <div id="zegar">
  2. <FORM name="clock" >
  3. <input type="text" name="face" size="6" value="">
  4. </FORM>
  5.  
  6. <script>
  7.  
  8. Stamp = new Date();
  9. year = Stamp.getYear();
  10. if (year < 2000) year = 1900 + year;
  11. document.write(Stamp.getDate() +"/"+(Stamp.getMonth() + 1) + "/"+ year);
  12.  
  13. var timerID = null;
  14. var timerRunning = false;
  15. function stopclock (){
  16. if(timerRunning)
  17. clearTimeout(timerID);
  18. timerRunning = false;
  19. }
  20. function showtime () {
  21. var now = new Date();
  22. var hours = now.getHours();
  23. var minutes = now.getMinutes();
  24. var seconds = now.getSeconds()
  25. var timeValue = "" + ((hours >24) ? hours -24 :hours)
  26. if (timeValue == "0") timeValue = 12;
  27. timeValue += ((minutes < 10) ? ":0" : ":") + minutes
  28. timeValue += ((seconds < 10) ? ":0" : ":") + seconds
  29. timeValue += (hours >= 24) ? " " : " "
  30. document.clock.face.value = timeValue;
  31. timerID = setTimeout("showtime()",1000);
  32. timerRunning = true;
  33. }
  34. function startclock() {
  35. stopclock();
  36. showtime();
  37. }
  38. // End -->
  39. </SCRIPT>
  40.  
  41. </div>

Go to the top of the page
+Quote Post
gargamel
post
Post #5





Grupa: Zarejestrowani
Postów: 278
Pomógł: 35
Dołączył: 25.06.2010

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


Zamiast:
  1. <div id="zegar">
  2. <FORM name="clock" >
  3. <input type="text" name="face" size="6" value="">
  4. </FORM>

Daj:
  1. <div id='clock' style='width:100px; border:1px solid black;'></div>


Natomiast w kodzie JS
Linię 30 czyli
  1. document.clock.face.value = timeValue;


Zmień na
  1. document.getElementById('clock').innerHTML = timeValue;
Go to the top of the page
+Quote Post
kubakuba
post
Post #6





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 18.01.2011

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


Na wstępie powiem, że w przypadku formularza dopisałem w
input disabled="disabled" i działa tak jak chciałem

Ale jako, że na samym początku chciałem umieścić zegar bez formularza, zastosowałem się do podanych przez "Gargamela" instrukcji.

Jest elegancko ale teraz zniknęła mi data.

Próbowałem sobie z tym poradzić i
jak na razie kod wygląda tak

  1. <div id="clock">
  2. <div id="date">
  3.  
  4. <script>
  5.  
  6. Stamp = new Date();
  7. year = Stamp.getYear();
  8. if (year < 2000) year = 1900 + year;
  9. document.write(Stamp.getDate() +"/"+(Stamp.getMonth() + 1) + "/"+ year);
  10. </SCRIPT>
  11. </div>
  12. <script>
  13. var timerID = null;
  14. var timerRunning = false;
  15. function stopclock (){
  16. if(timerRunning)
  17. clearTimeout(timerID);
  18. timerRunning = false;
  19. }
  20. function showtime () {
  21. var now = new Date();
  22. var hours = now.getHours();
  23. var minutes = now.getMinutes();
  24. var seconds = now.getSeconds()
  25. var timeValue = "" + ((hours >24) ? hours -24 :hours)
  26. if (timeValue == "0") timeValue = 12;
  27. timeValue += ((minutes < 10) ? ":0" : ":") + minutes
  28. timeValue += ((seconds < 10) ? ":0" : ":") + seconds
  29. timeValue += (hours >= 24) ? " " : " "
  30. //document.clock.face.value = timeValue;
  31. document.getElementById('clock').innerHTML = timeValue;
  32. timerID = setTimeout("showtime()",1000);
  33. timerRunning = true;
  34. }
  35. function startclock() {
  36. stopclock();
  37. showtime();
  38. }
  39. // End -->
  40. </SCRIPT>
  41.  
  42. </div>


a tu fragment kodu z szablonu CSS

  1. #clock {
  2. position: absolute; right:36px; top:16px;
  3. color:#C47DD1;
  4. border: solid 2px #1D330A;
  5. width:30px;
  6.  
  7. }
  8.  
  9. #date{
  10. position: absolute; right:36px; top:22px;
  11. color:#C47DD1;
  12. border: solid 2px #1D330A;
  13. width:30px;
  14. }
Go to the top of the page
+Quote Post
gargamel
post
Post #7





Grupa: Zarejestrowani
Postów: 278
Pomógł: 35
Dołączył: 25.06.2010

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


1 linia : <div id="clock"></div> i wtedy spróbuj.

Edit:

Działający gotowiec:
  1. <div id="clock"></div>
  2.  
  3. <div id="date">
  4. <script type='text/javascript'>
  5.  
  6. Stamp = new Date();
  7. year = Stamp.getYear();
  8. if (year < 2000) year = 1900 + year;
  9. document.write(Stamp.getDate() +"/"+(Stamp.getMonth() + 1) + "/"+ year);
  10. </SCRIPT>
  11. </div>
  12. <script type='text/javascript'>
  13. var timerID = null;
  14. var timerRunning = false;
  15. function stopclock (){
  16. if(timerRunning)
  17. clearTimeout(timerID);
  18. timerRunning = false;
  19. }
  20. function showtime () {
  21. var now = new Date();
  22. var hours = now.getHours();
  23. var minutes = now.getMinutes();
  24. var seconds = now.getSeconds()
  25. var timeValue = "" + ((hours >24) ? hours -24 :hours)
  26. if (timeValue == "0") timeValue = 12;
  27. timeValue += ((minutes < 10) ? ":0" : ":") + minutes
  28. timeValue += ((seconds < 10) ? ":0" : ":") + seconds
  29. timeValue += (hours >= 24) ? " " : " "
  30. //document.clock.face.value = timeValue;
  31. document.getElementById('clock').innerHTML = timeValue;
  32. timerID = setTimeout("showtime()",1000);
  33. timerRunning = true;
  34. }
  35. function startclock() {
  36. stopclock();
  37. showtime();
  38. }
  39. // End -->
  40. startclock();
  41. </SCRIPT>


Ten post edytował gargamel 12.02.2011, 17:38:01
Go to the top of the page
+Quote Post
kubakuba
post
Post #8





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 18.01.2011

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


Ok zmieniłem pierwszą linijkę i wszystko jest w porządku!

Dziękuję bardzo!
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 23.12.2025 - 08:34