Post
#1
|
|
|
Grupa: Zarejestrowani Postów: 256 Pomógł: 7 Dołączył: 1.01.2005 Ostrzeżenie: (0%)
|
Mam 5 inputów o id='g5'. Czy da się je wszystkie zablokować naraz? Zrobiłem coś takiego
Kod function acc(group) { val = document.getElementById(group).disabled; if(val == true) { document.getElementById(group).disabled=false; } else { document.getElementById(group).disabled=true; } } Ale po wywołaniu funkcji Cytat acc("g5") blokuje się tylko pierwszy input (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
|
|
|
|
![]() |
Post
#2
|
|
|
Grupa: Zarejestrowani Postów: 256 Pomógł: 7 Dołączył: 1.01.2005 Ostrzeżenie: (0%)
|
Idąc za Twoją radą zrobiłem coś takiego
Kod function getElementsByClassName(cn){ var arr = new Array(); var els = document.getElementsByTagName("*"); var exp= new RegExp("^(.* )?"+cn+"( .*)?$", "g"); for (var i = 0; i < els.length; i++ ){ if (exp.test(els[i].className)){ arr.push(els[i]); } } return arr; } Kod function acc(group) { val = getElementsByClassName(group); all = val.length; for($a = 0; $a < all; $a++) { inpu = val[$a].name; disable = document.getElementById(inpu).disabled; if(disable == true) { document.getElementById(inpu).disabled=false; } else { document.getElementById(inpu).disabled=true; } } } Nawet działa (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Może dało się to zrobić dużo prościej, ale w JS jestem początkujący (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) Dzięki (IMG:http://forum.php.pl/style_emoticons/default/Rkingsmiley.png) |
|
|
|
Hectic [JS] Zablokowanie kilku inputów 30.06.2007, 15:49:09
shovit Z tego co wiem id jest identyfikatorem danego elem... 30.06.2007, 15:56:16
Hectic Bardziej chodziło mi o to czy ktoś mam pomysł na r... 30.06.2007, 17:04:01
flv Kodfunction acc(it)
{
val = it.disabled... 30.06.2007, 17:15:18
abc667 albo
[HTML] pobierz, plaintext function acc(s... 30.06.2007, 18:08:23 ![]() ![]() |
|
Aktualny czas: 26.12.2025 - 08:08 |