pdm91
(Pramodmahale92)
March 24, 2014, 11:41am
1
Hi all,
Currently i have one form in which i want to hide the text fields based on the selection from dropdownlist.
I have tried to resolve this problem but don’t get any output from it.
I have tried following code in my form:
$(function(){
if($("#DropDownTextFiledName").Val() == 2)
{
$("TextFieldName").hide();
}
});
And i have declared 1=show & 2=hide.
1cichy
(Czaty)
March 24, 2014, 1:04pm
2
Use .change() trigger:
$( "#DropDownTextFiledName" ).change(function() {
if($( this ).val() == 2){
$("TextFieldName").hide();
} else {
$("TextFieldName").show();
}
});
pdm91
(Pramodmahale92)
March 25, 2014, 6:33am
3
Thanks for the reply…
I have put this code in
<script>
</Script>
at the start of the form but it doesn’t works.
Can u plz send me any sample code of such type of form?
pdm91
(Pramodmahale92)
March 25, 2014, 8:53am
4
Thanks for the reply…
I have put this code in
<script>
</Script>
at the start of the form but it doesn’t works.
Can u plz send me any sample code of such type of form?
1cichy
(Czaty)
March 25, 2014, 8:57am
5
georaldc
(Georaldc)
March 26, 2014, 7:56pm
6
The script needs to occur after the element has been rendered, or you could wrap it inside jquery’s ready function. You could also use something like this at the top of your view file:
Yii::app()->clientScript->registerScript('any_unique_id', "
$( "#DropDownTextFiledName" ).change(function() {
if($( this ).val() == 2){
$("TextFieldName").hide();
} else {
$("TextFieldName").show();
}
});
");