Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript][jQuery]input checkbox odblokowanie pól do edycji
@rtur
post 7.12.2014, 14:20:09
Post #1





Grupa: Zarejestrowani
Postów: 254
Pomógł: 3
Dołączył: 23.02.2006

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


Mam formularz:
  1. <tr><td class="col1"><input type "checkbox" name="no[]"></td><td class="col3"><input type="text" name="imie[]" disabled></td><td class="col3"><input type="text" name="nazwisko[]" disabled></td></tr>
  2. <tr><td class="col1"><input type "checkbox" name="no[]"></td><td class="col3"><input type="text" name="imie[]" disabled></td><td class="col3"><input type="text" name="nazwisko[]" disabled></td></tr>
  3. <tr><td class="col1"><input type "checkbox" name="no[]"></td><td class="col3"><input type="text" name="imie[]" disabled></td><td class="col3"><input type="text" name="nazwisko[]" disabled></td></tr>
  4. <tr><td class="col1"><input type "checkbox" name="no[]"></td><td class="col3"><input type="text" name="imie[]" disabled></td><td class="col3"><input type="text" name="nazwisko[]" disabled></td></tr>
  5. </form>


Ilość wierszy jest dynamiczna, w formularzu mogę zaznaczyć wiele pól typu checkbox. Jak w jQuery odblokować wszystkie pola input z wiersza w którym zaznaczono checbox? W sumie z samym zdjęciem atrybutu disabled z pól bym sobie może i poradził tylko nie wiem jak wykryć zaznaczenie checkboxa i wszystkie pozostałe pola tylko z jednego wiersza....


--------------------
Artur
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 6)
trueblue
post 7.12.2014, 14:33:27
Post #2





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


  1. if(inputChk.prop('checked'))
  2. inputChk.parent().parent().find('input[type="text"]').removeProperty('disabled');


--------------------
Go to the top of the page
+Quote Post
@rtur
post 21.12.2014, 10:09:20
Post #3





Grupa: Zarejestrowani
Postów: 254
Pomógł: 3
Dołączył: 23.02.2006

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


dziękuje, ale chyba coś robię nie tak bo nie działa, gdzie jest problem?
  1. $('input.alo').change(function(){
  2. var inputChk =$(this);
  3. if(inputChk.prop('checked'))
  4. inputChk.parent().parent().find('input[type="text"]').removeProperty('disabled');
  5. })

  1. <tr>
  2. <td class="checkbox"><input type="checkbox" name="alp[]" class="alo" value="139"></td>
  3. <td class="song-lp"><input type="text" name="lp[]" class="" disabled></td>
  4. <td class="song-time"><input type="text" name="time[]" value="" class="" placeholder="00:00:00" disabled></td>
  5. <td class="album-artist"><div class="title">Faith</div><div class="artist">George Michael</div></td>
  6. </tr>
  7. <tr>
  8. <td class="checkbox"><input type="checkbox" name="alp[]" class="alo" value="135"></td>
  9. <td class="song-lp"><input type="text" name="lp[]" class="" disabled></td>
  10. <td class="song-time"><input type="text" name="time[]" value="" class="" placeholder="00:00:00" disabled></td>
  11. <td class="album-artist"><div class="title">Symphonica</div><div class="artist">George Michael</div></td>
  12. </tr>


Ten post edytował @rtur 21.12.2014, 10:11:04


--------------------
Artur
Go to the top of the page
+Quote Post
trueblue
post 21.12.2014, 10:18:25
Post #4





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


click nie change.


--------------------
Go to the top of the page
+Quote Post
@rtur
post 21.12.2014, 10:50:53
Post #5





Grupa: Zarejestrowani
Postów: 254
Pomógł: 3
Dołączył: 23.02.2006

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


dałem .click i bez zmian, pojawia się błąd Uncaught TypeError: undefined is not a function
http://jsfiddle.net/4ond2ogm/


--------------------
Artur
Go to the top of the page
+Quote Post
trueblue
post 21.12.2014, 11:04:38
Post #6





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


Mój błąd.
.removeProp('disabled');

I dodaj znacznik table.


--------------------
Go to the top of the page
+Quote Post
@rtur
post 21.12.2014, 11:44:01
Post #7





Grupa: Zarejestrowani
Postów: 254
Pomógł: 3
Dołączył: 23.02.2006

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


Popróbowałem trochę i zadziałało tak
  1. $('input.alo').click(function(){
  2. var inputChk =$(this);
  3. if(inputChk.prop('checked'))
  4. inputChk.parent().parent().find('input[type="text"]').prop("disabled", false);
  5. else inputChk.parent().parent().find('input[type="text"]').prop("disabled", true);
  6. });


--------------------
Artur
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.07.2025 - 07:36