Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- function control(){
- var $building = $('#gcs_guest_registration_buildingId');
- var $floor = $('#gcs_guest_registration_floorId');
- // When sport gets selected ...
- $('form select').on('change', function(){
- // ... retrieve the corresponding form.
- var $form = $(this).closest('form');
- // Simulate form data, but only include the selected sport value.
- var data = {};
- data[$building.attr('name')] = $building.val();
- data[$floor.attr('name')] = $floor.val();
- //data[$building.attr('name')] = $building.val();
- data['_csrf_token'] = $('#gcs_guest_registration__token').val();
- // Submit data via AJAX to the form's action path.
- $.ajax({
- url : $form.attr('action'),
- type: $form.attr('method'),
- data : data,
- success: function(html) {
- $form.html($(html).find('form'));
- control();
- // Replace current position field ...
- //$('#gcs_guest_registration_floorId').replaceWith(
- // ... with the returned one from the AJAX response.
- //$(html).find('#gcs_guest_registration_floorId')
- // Position field now displays the appropriate positions.
- }
- });
- });
- }
- control();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement