Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: pole text ze statusem disabled, jak go uaktywnić javascriptem?
Forum PHP.pl > Forum > Po stronie przeglądarki
miedzna
Mam pole tekstowe <input text disabled> domyslnie nieaktywne. Obok pola mam radiobutton, jak zrobić, żeby po zaznaczeniu tego radiobuttona pole tekstowe zrobiło się aktywne, a jak się zaznaczy inny rediobutton, to znowu nieaktywne?

Kombinowałem jakoś tak, ale nie działa:

  1. <input type="radio" name="a" onclick="javascript:check();" id="g1a">
  2. <input type="text" name="aaa" id="aaa" value="Wpisz..." onblur="if (this.value=='') this.value = 'Wpisz...';" onfocus="if (this.value=='Wpisz...') this.value = '';" disabled>



oraz java script:

  1. function check(){
  2.  
  3. if(document.getElementById('g1a').checked == true){
  4. document.getElementById('aaa').disabled=false;
  5. }
  6. else{
  7. document.getElementById('aaa').disabled=true;
  8. }
  9. }
nospor
Mi tam dziala.
Kod
function check(obj){

    if(obj.checked){
        document.getElementById('aaa').disabled=false;
    }
    else{
        document.getElementById('aaa').disabled=true;
    }
}

  1. <input type="radio" name="a" onclick="check(this);" id="g1a">
  2. <input type="text" name="aaa" id="aaa" value="Wpisz..." onblur="if (this.value=='') this.value = 'Wpisz...';" onfocus="if (this.value=='Wpisz...') this.value = '';" disabled>

Patrzyles czy ci wogole wszedl do check()?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.