Tanlangan qiymatni radio tugmachasida ko'rsatish

HTML kodini yozish, bu erda muvaffaqiyatli topshiriq bilan tanlagan qiymatni tekshirmoqchiman. Radio tugmasidan tanlagan qiymatni ko'rmadim.

*

    <input name="ec" class="g" type="radio" value="E" disabled="'disabled'" checked="checked">
        E
        
*

Muammoni hal qilish uchun nima qilishim kerak?

0
Javascript kodini almashish mumkinmi?
qo'shib qo'ydi muallif Roli Agrawal, manba

7 javoblar

uning ishi @Afnan aytganidek yaxshi. ammo sizda bir nechta radiouzangiz bo'lsa va tanlangan radio tugmai qiymatiga ega bo'lishingiz kerak bo'lsa, buni amalga oshirishingiz kerak

    var radio= [];
    $.each($("input[name='sport']:checked"), function(){            
        favorite.push($(this).val());
    });
    alert("My selected checkbox  are: " + favorite.join(", "));

va yaah faylini skript faylini qo'shish kerakligini aytishni unutma ..

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
0
qo'shib qo'ydi
OO jQuery haqida so'zlamadi
qo'shib qo'ydi muallif Hidayt Rahman, manba

Vanilla JavaScript-ni

Agar radio tekshirilganda radiosi qiymatini ko'rsatishni xohlasangiz, faqatgina yozing

if (document.getElementById('s').checked) { 
   selectedVal = document.getElementById('s').value; 
}

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

if (document.getElementById('s').checked) {
  selectedVal = document.getElementById('s').value;
}
alert(selectedVal);
<input name="ec" class="g" type="radio" id="s" value="E" disabled="'disabled'" checked="checked"> E

*
</div> </div>
0
qo'shib qo'ydi

Vanilla JavaScript-ni

Agar radio tekshirilganda radiosi qiymatini ko'rsatishni xohlasangiz, faqatgina yozing

if (document.getElementById('s').checked) { 
   selectedVal = document.getElementById('s').value; 
}

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

if (document.getElementById('s').checked) {
  selectedVal = document.getElementById('s').value;
}
alert(selectedVal);
<input name="ec" class="g" type="radio" id="s" value="E" disabled="'disabled'" checked="checked"> E

*
</div> </div>
0
qo'shib qo'ydi

You cant get disabled values on your post actions. Just don't make the radio button disabled and it will get the value if it's checked, or you can make it ReadOnly like that: <input name="ec" class="g" type="radio" value="E" readonly="readonly" checked="checked">

Ushbu StackOverflow javobiga qarash

0
qo'shib qo'ydi

You cant get disabled values on your post actions. Just don't make the radio button disabled and it will get the value if it's checked, or you can make it ReadOnly like that: <input name="ec" class="g" type="radio" value="E" readonly="readonly" checked="checked">

Ushbu StackOverflow javobiga qarash

0
qo'shib qo'ydi

You can get it like the following snippet with jquery

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

alert($('input[name=ec]:checked').val())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input name="ec" class="g" type="radio" value="E" disabled="'disabled'" checked="checked">
        E
        
*
</div> </div>
0
qo'shib qo'ydi
Yuqoridagi parchadan foydalanmoqchi bo'lsangiz. Yuqoridagi snippetdagi kabi jQuery ni qo'shishingiz kerak.
qo'shib qo'ydi muallif Afnan Ahmad, manba
Qaysi JavaScript faylini ishlatayotganimni bilmasam, Chrome brauzerida qanday qilib disk raskadrovka qilinishini tekshirish uchun bironta havolani ko'rdingizmi?
qo'shib qo'ydi muallif Rez D'Souza, manba

You can get it like the following snippet with jquery

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

alert($('input[name=ec]:checked').val())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input name="ec" class="g" type="radio" value="E" disabled="'disabled'" checked="checked">
        E
        
*
</div> </div>
0
qo'shib qo'ydi
Yuqoridagi parchadan foydalanmoqchi bo'lsangiz. Yuqoridagi snippetdagi kabi jQuery ni qo'shishingiz kerak.
qo'shib qo'ydi muallif Afnan Ahmad, manba
Qaysi JavaScript faylini ishlatayotganimni bilmasam, Chrome brauzerida qanday qilib disk raskadrovka qilinishini tekshirish uchun bironta havolani ko'rdingizmi?
qo'shib qo'ydi muallif Rez D'Souza, manba
Javascript UZB
Javascript UZB
99 ishtirokchilar

@js_uzb @vuejs_uz @react_uz @nodejs_uz @angular_uz @ngTashkent @yiiframework_uz @laravel_uz @linux_uzbek @python_uz @swift_uzb —————— @uzdevgroup @UzGeeksGroup ——— @UzDev_Jobs @jobs_uzb