I have this:
<?php
$list = [];
$list = [1 => 'Aumento' , 0 => 'Disminución'];
echo $form->field($modi, 'aumento')->radioList($list)->label("<b>Seleccione acción a realizar</b>");
?>
And I need to get the value of the vector "$list" with a function in javascript, I have:
$('#modificaciones-aumento').change(function(){
var valor = $('#modificaciones-aumento').val();
alert(valor);
});
But it is not working, I've tried using the function "prop.("checked")" as well, but it did not work either.
Your radio buttons don't have id
values. #modificaciones-aumento
is the id
of your div
<div id="modificaciones-aumento">
<label>
<input type="radio" name="Modificaciones[aumento]" value="1"> Aumento
</label>
<label>
<input type="radio" name="Modificaciones[aumento]" value="0"> Disminución
</label>
</div>
Try #modificaciones-aumento :radio
for your selector, and $(this)
in your function
$('#modificaciones-aumento :radio').change(function(){
var valor = $(this).val();
alert(valor);
});
jsFiddle - http://jsfiddle.net/d6mfuv0c/