Hi
In my applicaion I am using MVC 5. In that I need to show and hide text box based on dropdown list value. I have total 4 text box and 2 dropdown list values. If I select one dropdown value I need to show only 2 text box and remaining 2 text box are hide. and page loding time I need to show only 2 text box instead of 4. I am using Jquery.
dropdown value is - 1- show 2 text box
dropdown value is - 2 - show another 2 text box
default is show any 2 text box.
Thanks
Afzaal Ahmad ZeeshanPosted Mar 18, 2015, 12:16 PM
$('select').change(function () {
// handle the event...
if($(this).val() == 'some value') {
// show the textbox..
} else {
// show other textbox..
}
});
This way, you can define conditions to show either of the TextBox (which in HTML is an input element; so while handling this on the client-side use the input tag with the ID of the control), and hide others. To do this, you can use .hide() or .show() functions of the jQuery library.