1 year ago

how to display a select option when an initial select option is clicked with jquery

Posted 1 year ago by icelander

hi guys. this is my code but its not working

        function showcategory(){
            var selectBox = document.getElementById('category');
            var userInput = selectBox.options[selectBox.selectedIndex].value;
            if (userInput == $sel->id){
                document.getElementById('description').style.visibility = 'visible';
                document.getElementById('description').style.visibility = 'hidden';
            return false;

this is my select option to initially select 

Select Category
                                         <select class="form-control" id="category" name="category" onchange="return showcategory();">
                                                 @foreach($category as $sel)
                                         <option value=" {{$sel->id}}"> {{$sel->category}} </option>
this is the select option I want to be displayed with contents based on the previously selected option

@foreach($catid as $describe) {{$describe->problems}} @endforeach

am using Laravel. thanks

Please sign in or create an account to participate in this conversation.