Witam
Chcę zrobić element radio w formularzu i jeżeli zostanie wybrana pierwsza opcja to następnym polem w tym formularzu będzie pole typu text, jeśli wybiorę drugą opcję to wyświetli pole typu password. Jak to zrobić ?
<head> <script type="text/javascript"> $(function(){ $('input').change(function(){ switch($(this).val()) { case 'txt': $('.someClass').remove(); $('.container').append('<input class="someClass" type="text" />'); break; case 'pass': $('.someClass').remove(); $('.container').append('<input class="someClass" type="password" />'); break; } }); }); </script> </head> <body> <div class="container"> </div>
Opcja 1:<input type="radio" id="dataType" name="dataType" onchange="if (this.checked==true) document.getElementById('id1').style.display = 'block'"> Opcja 2 <input type="radio" id="dataType" name="dataType" onchange="if (this.checked==true) document.getElementById('id2').style.display = 'block'"> <input type="text" name="nr_konta" id="id1" style="display: none"/> <input type="text" name="nr_konta" id="id2" style="display: none"/>