我想在Laravel中进行注册页面(默认搭建),只需稍加调整即可。 我的输入上面有两个单选按钮,我在这里挣扎着javascript。 访客用户有两个选项,(用户或公司),如果用户选择“公司”按钮,它应显示与“用户”不同的输入。 现在我一直在谷歌看几个小时,这是最好的方法,但我尝试的一切都行不通。 我吮吸javascript ..
我尝试过这样的测试,但看起来我又走错了路。
$(document).ready(function() { if (document.getElementById('user').checked) { document.getElementById('#name').display = 'block'; } else if (document.getElementById('company').checked) { } });I want to make registration page in Laravel (default scaffolded) with little tweak. I have two radio buttons above my inputs and I'm struggling with javascript here. Guest user have two options, (user or company), if user will choose "company" button it should show different inputs than "user" has. For now I have been looking hours in google, what is best way to do it, but everything I try is doesn't work. I suck at javascript..
I have tried something like that just for testing, but looks like I'm again heading wrong way.
$(document).ready(function() { if (document.getElementById('user').checked) { document.getElementById('#name').display = 'block'; } else if (document.getElementById('company').checked) { } });最满意答案
尝试这样的东西,2个收音机就像:
<input type="radio" name="user_type" value="1" class="user_type"> User <input type="radio" name="user_type" value="2" class="user_type"> CompanyjQuery的:
$(document).ready(function() { $('.user_type').change(function(){ if( $(this).val() == 1 ) { // User section code here } else { // Company section code here } }); });Try something like this, the 2 radio's are like:
<input type="radio" name="user_type" value="1" class="user_type"> User <input type="radio" name="user_type" value="2" class="user_type"> CompanyJquery:
$(document).ready(function() { $('.user_type').change(function(){ if( $(this).val() == 1 ) { // User section code here } else { // Company section code here } }); });更多推荐
发布评论