Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> div +id +input type text +js
wouga
post 18.01.2007, 17:40:19
Post #1





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 2.06.2005

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


mam input:

<input type=text name=input><br>

mam divy:

<div id=mama>mama</div>
<div id=mata>mata</div>
<div id=mtma>mtma</div>
<div id=tama>tama</div>
<div id=tata>tata</div>
<div id=fama>fama</div>

i teraz tak w trakcie pisania w inpucie ma sie przez onkeyup (down) uruchamiać funkcja która
1. wszystkie divy daje na display none
i wyswietla tylko te ktore sprawdzają kryteria w inpucie przez wyrazenia reguralne czy coś innego
np. jak wpisze M/m

to wyswietla
mana
mata
mtma

a jak mama

to wyswietla

tylko mama

ps ilośc divów = X


prosze o pomoc poniewaz siedze nad tym od rana i nie moge wpaść na to
Go to the top of the page
+Quote Post
ferr
post 18.01.2007, 18:41:35
Post #2





Grupa: Zarejestrowani
Postów: 122
Pomógł: 3
Dołączył: 18.12.2004

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


Szefie - daj kod winksmiley.jpg


--------------------
Go to the top of the page
+Quote Post
wouga
post 18.01.2007, 19:22:00
Post #3





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 2.06.2005

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


<script>
function sprawdz(co)
{
document.getElementById(co).style.display='';
}
</script>
<input type=text onkeyup=sprawdz(this.value) name=kupa><br>
<div style="display: none" id=mama>mama</div>
<div style="display: none" id=mata>mata</div>
<div style="display: none" id=mtma>mtma</div>
<div style="display: none" id=tama>tama</div>
<div style="display: none" id=tata>tata</div>
<div style="display: none" id=fama>fama</div>
Go to the top of the page
+Quote Post
ferr
post 18.01.2007, 19:50:36
Post #4





Grupa: Zarejestrowani
Postów: 122
Pomógł: 3
Dołączył: 18.12.2004

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


  1. <?php
  2. <script>
  3. function sprawdz(co)
  4. {
  5. var divs = document.getElementsByTagName('div');
  6.  
  7. if (co != "")
  8. {
  9.  
  10.  
  11. for (= 0; i < divs.length; i++)
  12. {
  13. var szukanaFraza = new String(divs[i].innerHTML);
  14. var reg = "^"+co;
  15.  
  16. if (szukanaFraza.search(reg) != -1)
  17. {
  18. divs[i].style.display = 'block';
  19. }
  20. else
  21. {
  22. divs[i].style.display = 'none';
  23. }
  24. }
  25. }
  26. else
  27. {
  28.  
  29.  
  30. for (= 0; i < divs.length; i++)
  31. {
  32. divs[i].style.display = 'none';
  33. }
  34. }
  35.  
  36. }
  37. </script>
  38. <input type=text onkeyup="sprawdz(this.value)" name=kupa><br>
  39. <div style="display: none" id=mama>mama</div>
  40. <div style="display: none" id=mata>masa</div>
  41. <div style="display: none" id=mtma>mtma</div>
  42. <div style="display: none" id=tama>tama</div>
  43. <div style="display: none" id=tata>tata</div>
  44. <div style="display: none" id=fama>fama</div>
  45. </script>
  46. ?>


Dzialajaca prowizorka winksmiley.jpg


--------------------
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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 00:40