There is an object:
@foreach( $data as $row ) <div class='row' style='clear:both;width:1200px;'> @foreach( $row as $day=>$gymArray ) <div class='cell' style='width:170px;float:left;;text-align: center;max-height:370px;overflow: auto'> @foreach( $gymArray as $gym=>$gymInfo ) <div id="timetable-cell-gym" style='clear:both'> <p id="time-text">{{ $gymInfo[ 'time' ] or '' }}</p><hr id="hr-time" style="width:20%"/> <h5 style="margin-bottom: -6px; margin-top:-10px"><strong id="group-name">{{ $gymInfo[ 'group' ] or '' }}</strong></h5><br> {{ $gymInfo[ 'trainer' ] or '' }}<br><hr id="after-worker-line" style="width:70%; margin-bottom: 15px"/> <p style="margin-top: 9px"> {{ $gymInfo[ 'status' ] or '' }}</p> <small id="gym-name">{{ $gym or '' }}</small> </div> @endforeach </div> @endforeach </div> @endforeach When editing the form, the status select is displayed:
{!! Form::model($columns, ['class' => 'form', 'method' => 'PUT', 'route' => ['api.columns.update']]) !!} <input name="id" value="{!! $columns->id !!}" type="hidden"> <div class="form-group"> {!! Form::label('time', 'время', ['class' => 'control-label']) !!} {!! Form::text('time', null, ['class' => 'form-control']) !!} <p class="help-block">в формате: "8:25"</p> </div> <div class="form-group"> {!! Form::label('service_title', 'группа', ['class' => 'control-label']) !!} {!! Form::select('service_title', $groups, null, ['class' => 'form-control']) !!} </div> <div class="form-group"> {!! Form::label('worker_name', 'Тренер', ['class' => 'control-label']) !!} {!! Form::select('worker_name', $trainers, null, ['class' => 'form-control']) !!} </div> <div class="form-group"> {!! Form::label('timetable-select', 'статус', ['class' => 'timetable-select']) !!} {!! Form::select('timetable-select', $status, old('status'), ['class' => 'form-control']) !!} </div> <div class="buttons" align="right"> {!! Form::submit('Обновить', ['class' => 'btn btn-primary']) !!} <a class="btn btn-default" href="{{ url('api/columns') }}" style="background: #832032; color: #fffbd8;">Назад</a> {!! Form::close() !!} </div> It is necessary that when saving changes in this form, the status of an object is assigned. At the moment I tried this version of JS:
$(document).ready(function(){ if ($("#timetable-select").change){ className = $(this).val(); oldClassName = $("#timetable-cell-gym").attr("oldClass"); $("#timetable-cell-gym").attr("oldClass",className); $("#timetable-cell-gym").removeClass(oldClassName).addClass(className); } }); When updating the class of the object has not changed. How can I change the script for its performance?
#timetable-select(id) in thejsscript, and as I understood from the markup you haveclass="timetable-select", it should be necessary.timetable-select- Alexander Igorevich