Answer the question
In order to leave comments, you need to log in
Modx revo. How to submit a form without a submit button using ajax?
The site is dedicated to photo and video shooting and has the following structure:
Our works
|__Wedding
| |__Photo
| | |__Wedding photos of Anton and Peter: ) (resource containing photos)
| |__Video
| |__Video from wedding photos of Anton and Peter: )
|__Wedding
|__etc.
The "Our works" section is going to have a filter of the following nature: a
radio switch between the photo and video sections and a select with the name of the parent resource (for example, "Wedding"). By default, all child resources of the photo and video sections are displayed. I output using getPage:
[
<form action="" method="post" id="select-type-service">
<div class="container">
<div class="row">
<div class="col-lg-4">
<div class="jq-radio-photo">
<input type="radio" name="photo-radio" class="photo-radio" />
<p>Фотографии</p>
</div>
</div>
<div class="col-lg-4">
<div class="jq-radio-video">
<input type="radio" name="video-radio" class="video-radio" />
<p>Видеосъемка</p>
</div>
</div>
<div class="col-lg-4">
<select class="selectpicker" data-width="100%" name="service[]">
<option value="4">Все разделы</option>
<option value="23">свадьба</option>
<option value="26">Корпоратив</option>
<option value="29">Венчание</option>
<option value="32">Выписка из роддома</option>
<option value="35">Крестины</option>
<option value="38">Детский сад</option>
<option value="41">Школьные годы</option>
<option value="44">Студийное фото</option>
<option value="47">Фотопрогулки</option>
</select>
</div>
</div>
</div>
</form>
<?php
if ( $_POST['service'][0] == 4 && empty($_POST['photo-radio']) && empty($_POST['video-radio'])){
$allRes = '24, 25, 27, 28, 31, 30, 34, 33, 37, 36, 39, 40, 43, 42, 46, 49';
} elseif ( $_POST['service'][0] == 4 && isset($_POST['photo-radio']) && empty($_POST['video-radio'])) {
$resources = $modx->getCollection('modResource',array('alias' => 'video'));
foreach ($resources as $k => $res) {
$videoId .= $res->get('id'). ', ';
}
$videoRes = rtrim($videoId, ", ");
} elseif ($_POST['service'][0] == 4 && empty($_POST['photo-radio']) && isset($_POST['video-radio'])) {
$resources = $modx->getCollection('modResource',array('alias' => 'foto'));
foreach ($resources as $k => $res) {
$photoId .= $res->get('id'). ', ';
}
$photoRes = rtrim($photoId, ", ");
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question