papson
(Adrien Fm)
March 17, 2014, 4:46pm
1
hi all,
thxs for this rich forum, as a newbie in yii, i have problem to solve:
i would like to enable a textfield based on the entry of a previous one.
EX
user sets a value for field1
=> enable field1Dependent
else
=> disable field1Dependent
how can i proceed please.
yiibjorn
(Bjorn)
March 17, 2014, 4:58pm
2
I think by using Jquery to add a listener to the first field and let this function disable/enable the 2nd field depending on the value of the first field.
Keith
(Kburton)
March 17, 2014, 5:02pm
3
You can use some jquery in a script tag on your page. Something like this:
<script type="text/javascript">
$('body').on('change, keyup', '#idOfField1', function(){
$('#idOfField1Dependent').prop('disabled', $(this).val().length === 0);
});
</script>