Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [js]Okreslanie pozycji pola input
skowron-line
post
Post #1





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


Witam mam takie pytanie jak automatycznie okreslic pozycje pola input zeby móc pod nim wyswietlić div z podpowiedziami??


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post
mike
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

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


Quirksmode - JavaScript - Find position
Go to the top of the page
+Quote Post
zbig
post
Post #3





Grupa: Zarejestrowani
Postów: 144
Pomógł: 30
Dołączył: 5.05.2007
Skąd: Mannheim

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


  1. function findPos(obj)
  2. {
  3. var curleft = curtop = 0;
  4. if (obj.offsetParent) {
  5. curleft = obj.offsetLeft
  6. curtop = obj.offsetTop
  7. while (obj = obj.offsetParent) {
  8. curleft += obj.offsetLeft
  9. curtop += obj.offsetTop
  10. }
  11. }
  12.  
  13. return [curleft,curtop];
  14. }


pozdrawiam


--------------------
Flash Flex PHP JAVA RED5 http://www.easyweb24.net
Go to the top of the page
+Quote Post
skowron-line
post
Post #4





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


  1. <script type="text/javascript">
  2.  
  3. function showHint(left,top){
  4. var a = document.getElementById('a');
  5. a.style.display="block";
  6. a.style.top = top+"px";
  7. a.style.left = left+"px";
  8. }
  9.  
  10. function findPos(obj)
  11. {
  12. var curleft = curtop = 0;
  13. if (obj.offsetParent) {
  14. curleft = obj.offsetLeft
  15. curtop = obj.offsetTop
  16. while (obj = obj.offsetParent) {
  17. curleft += obj.offsetLeft
  18. curtop += obj.offsetTop
  19. }
  20. }
  21. alert(curleft+' and '+curtop);
  22. showHint(curleft,curtop);
  23. //return [curleft,curtop];
  24. }
  25.  
  26.  
  27. <div id="a" style="display:none;">tekst tekst</div>
  28. <center><input type="text" id="in" onclick="findPos('in');"></center>

alert zwraca 0 and 0
co zrobilem zle??
sprawdzalem pod IE FF i Mozareli

@zbig nabijasz sobie posty??

Ten post edytował skowron-line 19.09.2007, 09:31:31


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post
nospor
post
Post #5





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




findPos przyjmuje obiekt a nie id....
zamiast: onclick="findPos('in');"
daj: onclick="findPos(this);"

@zbig nie nabijaj tak bezczelnie postów!!!


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
skowron-line
post
Post #6





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


dzieki nospor o to chodzilo teraz dziala jak powinno


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
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: 20.08.2025 - 12:29