Support the ongoing development of Laravel.io →
Blade Forms

How can I submit without refreshing the page?

here is my code

Route::get ('building/{id}/editsystem/{sid}/webmapping/dashboardmaps', ['as'=>'dashboardmaps.edit', 'uses'=>'BuildingController@editDashboardMaps']);
      Route::post ('building/{id}/editsystem/{sid}/webmapping/dashboardmaps', ['as'=>'dashboardmaps.update', 'uses'=>'BuildingController@updateDashboardMaps']);

view as follows

                                   {{ Form::open() }} 
                                            @foreach($newAvailableDevices as $newAvailableDevice)
                                                    @if($newAvailableDevice['name'] == 1)
                                                          {{   $newAvailableDevice['name'] = "there is no Device Available"; }}
                                                @endif
                                                     <option value="{{$newAvailableDevice['id']}},{{$newAvailableDevice['command']}},{{ $newAvailableDevice['name']}}"  >    
                                                            Zone: {{ ConvFunc::findzonename($zonenames, $newAvailableDevice['zone'])}} -> Name:{{ $newAvailableDevice['name']}} --- ID:{{$newAvailableDevice['id']}} ---  {{$newAvailableDevice['commandString']}} sensor
                                                     </option>
                                            @endforeach
                                                {{Form::hidden('id','',['id'=>'AddElementid','style'=>'color:black'] ) }}
                                                {{Form::hidden('command','',['id'=>'AddElementCommand','style'=>'color:black'] ) }}
                                                {{Form::hidden('label','',['id'=>'AddElementName','style'=>'color:black'] ) }}
                                                {{Form::hidden('x_position','00',['id'=>'x_position','style'=>'color:black'] ) }}
                                                {{Form::hidden('y_position','00',['id'=>'y_position','style'=>'color:black'] ) }}
                                                {{Form::text('map_idForNew','0',['id'=>'map_idForNew','style'=>'color:black'] ) }}
                                                </optgroup>  
                                        </select>
                                      {{Form::submit('Create the Element', ['value'=>'SavetheDevice','name'=>'SavetheDevice' ,'style'=>'color:black']) }}   
                                      {{Form::submit('Add Season',['value'=>'AddSeason', 'name'=>'AddSeason' ,'style'=>'color:black'])}}
                                    {{  Form::close()  }}

here is the code in controller

      if(Input::get('AddSeason')){
          $newItem->command = 333;
          $newItem->device_id = 333;
          $newItem->x_position = 00;
          $newItem->y_position = 00;
          $newItem->label = 'Season';
          $a = Input::get('map_idForNew');
          $newItem->map_id = $selectMaps[Input::get('map_idForNew')]->id;
          $existing = 0;

              foreach($DashboardMapItems as $DashboardMapItem){
                  if(($DashboardMapItem->map_id == $newItem->map_id) && ($DashboardMapItem->label == $newItem->label)){
                     $existing = 1;
                  }
                }
                if( $existing == 0){
                  $newItem->save();
                  Session::flash("success", "the Season Tag was successfully created");
                }else{
                  Session::flash("error", "the Season Tag is already exist");
                }
      }

this code works, but i was wondering what to do to make the page submit without refreshing

Last updated 3 years ago.
0

@AlbertDem

If your situation support ajax you can try that I think.

Thanks :)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

AlbertDem albertdem Joined 3 Jun 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.