Laravel和隐藏的输入(Laravel and hidden inputs)

编程入门 行业动态 更新时间:2024-10-26 03:26:24
Laravel和隐藏的输入(Laravel and hidden inputs)

我想在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"> Company

jQuery的:

$(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"> Company

Jquery:

$(document).ready(function() { $('.user_type').change(function(){ if( $(this).val() == 1 ) { // User section code here } else { // Company section code here } }); });

更多推荐

本文发布于:2023-08-03 16:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1393317.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Laravel   hidden   inputs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!