12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- use yii\helpers\Html;
- use yii\helpers\Url;
- use app\models\Inquirer;
- use yii\web\View;
- if( $model->active == 'Y' && $model->show == 'Y' ){
- $answers = $model->getAnswers();
- foreach($answers as $item){
- ?>
- <div class="form-check">
- <input class="form-check-input" type="radio" id="Radio<?=$item->id?>" name="ask" value="<?=$item->id?>">
- <label class="form-check-label" for="Radio<?=$item->id?>">
- <?=$item->text?>
- </label>
- </div>
- <?
- }
- }
- ?>
- <button class="btn btn-primary mt-4" onclick="sendask()">Голосовать</button>
- <?
- $filterurl = \yii\helpers\Url::base('https')."/inquirer/ajax";
- $this->registerJs(
- <<<JS
- function sendask(){
- ask = $('input:checked[name=ask]').val()
- $.post( "$filterurl", { 'idq': $model->id, 'ask': ask }, function( data ) {
- if( data.status == 'ok' ){
- document.location.reload();
- }
- });
- }
- JS
- ,
- View::POS_END
- );
|