Enable/Disable or Hide/Show Form Fields Based on Select "change" Event

2,429 views
Skip to first unread message

Tami Wright

unread,
Nov 7, 2012, 9:14:21 PM11/7/12
to ang...@googlegroups.com
Greetings Everyone,

I'm moving into the AngularJS world from JQuery and am not quite sure how to translate a particular use case which is a no brainer in JQuery.  That use case is enabling/disabling or hiding/showing form elements based on the change of a select element in the same form.  Any ideas/suggestions/pointers anyone would be willing to share to help me get this working?

And for an idea of what I'm trying to do here is some code to illustrate:

$('#ddl').change( function (e) {
                var selectedValue = $(this).val();
                switch(selectedValue){
                    case 1:
                         // Hide/show or enable/disable form elements here with Javascript or Jquery
 
// Sample enable code 
            document.getElementById("username").readOnly = false;
            document.getElementById("username").style.background = "transparent";
            document.getElementById("username").style.color = "#000000"; 

 
// Sample disable code 
            document.getElementById("first_name").readOnly = true;
            document.getElementById("first_name").style.color = "#c0c0c0"; 
                                    break;          
                }
                return false;
            });

Thank you in advance,

Tami Wright 

Peter Bacon Darwin

unread,
Nov 8, 2012, 6:25:35 AM11/8/12
to ang...@googlegroups.com
Answered on Stack Overflow: http://stackoverflow.com/questions/13288136/what-is-the-angularjs-way-to-show-or-hide-a-form-element

Pete

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
 
 

Reply all
Reply to author
Forward
0 new messages