jeudi 3 août 2017

How to pre-select select statements in Laravel

I have a select statement with a large number of options to select. I am retrieving all of the options from my back-end and filling them in. However I would also like to select an option, which I also pass in from my backend. My code is as follows:

@for($i=0; $i<sizeof($info['userInfo']['courses']); $i++) //
            <tr class="table_row">
                <td><select class="form-control" name="TB1_instructions_course[]" id="course" required="" value=''>
                        <option value="">Course</option>
                        @foreach($info['staticInfo']['courses'] as $course) //pull in static data
                        <option></option>
                        @endforeach
                    </select></td>
                <td><input type="text" class="form-control" placeholder="C01" name="TB1_instructions_section[]" id='section' required="" value=''></td>
                <!-- the rest of the table-->

Now the text field works perfectly and populates it accordingly, but I am unable to select the appropriate option in my select input. Any help? Can I do this without using jQuery or javascript?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2hrsdC3
via IFTTT

Aucun commentaire:

Enregistrer un commentaire