Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> pole text ze statusem disabled, jak go uaktywnić javascriptem?
miedzna
post 30.10.2007, 12:15:49
Post #1





Grupa: Zarejestrowani
Postów: 401
Pomógł: 1
Dołączył: 10.03.2004
Skąd: Warszawa

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


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. }
Go to the top of the page
+Quote Post
nospor
post 30.10.2007, 12:34:13
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




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()?


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

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 - 09:35