Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript]Skrypt który chowa tekst, problem...
Skr3czu
post 5.07.2009, 14:52:54
Post #1





Grupa: Zarejestrowani
Postów: 215
Pomógł: 0
Dołączył: 12.03.2007

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


Witam,

mam taki skrypt:
Kod
<div ><input type="button" value="1.Czy można mieć 10 samochodów ?" style="width:500px;font-size:10px;margin:0px;padding:0px; margin-right:0px;" onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = '1.Czy można mieć 10 samochodów ?'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = '1.Czy można mieć 10 samochodów ?'; }">
</div>
<div style="margin: 0px; padding:0px;">
<div style="display: none;">
Tak oczywiście, że można mieć...
</div>
</div>

No i działa dobrze, ale jak go na jednej podstronie umieszczę dwa razy, czyli tak:
Kod
<div ><input type="button" value="1.Czy można mieć 10 samochodów ?" style="width:500px;font-size:10px;margin:0px;padding:0px; margin-right:0px;" onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = '1.Czy można mieć 10 samochodów ?'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = '1.Czy można mieć 10 samochodów ?'; }">
</div>
<div style="margin: 0px; padding:0px;">
<div style="display: none;">
Tak oczywiście, że można mieć...
</div>
</div>
<br>
<div ><input type="button" value="1.Czy można mieć 10 samochodów ?" style="width:500px;font-size:10px;margin:0px;padding:0px; margin-right:0px;" onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = '1.Czy można mieć 10 samochodów ?'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = '1.Czy można mieć 10 samochodów ?'; }">
</div>
<div style="margin: 0px; padding:0px;">
<div style="display: none;">
Tak oczywiście, że można mieć...
</div>
</div>

To jakby nie działają...

Co jest nie tak ?
Go to the top of the page
+Quote Post
singles
post 5.07.2009, 15:07:36
Post #2





Grupa: Zarejestrowani
Postów: 121
Pomógł: 26
Dołączył: 2.07.2007

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


Cytat(Firebug)
this.parentNode.parentNode.getElementsByTagName("div")[1].getElementsByTagName("div")[0] is undefined


Sprawdź, czy nie za dużo tego parentNode.

Ten post edytował singles 5.07.2009, 15:08:19


--------------------
Works for me => u mnie działa - blog o (o)programowaniu i nie tylko
meet.php - darmowe meetupy związane z PHP
Go to the top of the page
+Quote Post
Skr3czu
post 5.07.2009, 15:09:54
Post #3





Grupa: Zarejestrowani
Postów: 215
Pomógł: 0
Dołączył: 12.03.2007

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


Dzięki, już sobie poradziłem 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: 17.06.2025 - 16:17