-1

I have following code

    <div class="form-group">
        <select class="form-control" name="persons">
            <option value="1">{{Lang::get('user')}}</option>
            <option value="0">{{Lang::get('admin')}}</option>
        </select>
    </div>

I want something like this if is selected the option with value = 1 to show an input like this

<div class="form-group">
                {{ Form::text('name','',['required', 'class'=>'form-control', 'placeholder'=>Lang::get('user_name')]) }}
            </div>

else if the value is 0

<div class="form-group">
                {{ Form::text('admin','',['required', 'class'=>'form-control', 'placeholder'=>Lang::get('admin_name')]) }}
            </div>

I'm new in Laravel and I don't know how to show inputs by value.

Ricardo Velhote
  • 4,630
  • 1
  • 24
  • 30

1 Answers1

0

acually this is DOM issues

$('#persons').on('change', function(){
  var value = $(this).val();
  $('.form').find('div').addClass('hide');
if(value === 1){
 $('.form').find('.one').remove('hide')
 $('.form').find('.one').addClass('show')
}else{
    $('.form').find('.two').remove('hide')
 $('.form').find('.two').addClass('show')
}
});

enter code here

i made example . refer i update code

https://jsfiddle.net/channasmcs/5fmmLqax/

thanks

refre on change JQ jQuery select change show/hide div event

Community
  • 1
  • 1
channasmcs
  • 1,104
  • 12
  • 27