Home > Enterprise >  How to get yii2 clicked radioList value in Jquery?
How to get yii2 clicked radioList value in Jquery?

Time:11-23

I have this in my form

<?= $form->field($model, 'system_user')->inline(true)->radioList(["Yes"=>"Yes","No"=>"No"],['onClick'=>'getValue($(this).val());','id'=>'system_user']) ?>

and I need to get the value of clicked radio button in Jquery/javascript, and I have implimented this

<script>
function getValue($value){
        alert($value);
    }
</script>

But it gives empty alert. Any one to assist please, I have stacked for a day now.

CodePudding user response:

You could add an event manager fur input:radio

  $("input:radio[name='your_field_name']:checked").val();

and for yii2

$("input:radio[name='modelName[fieldName]']:checked").val();
  • Related