mercredi 30 mars 2016

Hidden input value should be changed when selecting a item from drop box in laravel 5

Here is my drop box and then after the hidden box. These are inside the form.

 <tr>
     <td> <b>{!! Form::label('Types', 'Type') !!}</b></td>

     <td> {!! Form::select('type', array('type' => 'type','Orange' => 'Orange', 'Red' => 'Red','Green' => 'Green'), 'type') !!}</td>
</tr>

{!! Form::hidden('color') !!}

Script is below after the form.

<script>
    $(document).ready(function () {
        $('#type').on('change', function () {
            $('#color').val($(this).val());

        });
        $('#Orange').on('change', function () {
            $('#color').val($(this).val());
        });
        $('#Red').on('change', function () {
            $('#color').val($(this).val());
        });
        $('#Green').on('change', function () {
            $('#color').val($(this).val());
        });
    });
</script>

Hidden input value get empty after the execution. Where am I wrong. Please can you help that out for me?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire