I'm trying to make a from where some text fields are hidden by default and will be show only when specific option from <option > box is selected.
I've done this using jquery but the way I made it is really very poor. I need to set the all child text area's or option box's values to blank when any parent option is changed.
So I'm using this jquery to get it done
$('#parent').change(function() {
if ($(this).val() == 'child1') {
$('#child1').show() ;
$('#child2').hide() ;
$('#child2').val('');
and so on.
I 3 levels of parent child and I have to repeat this for every parent and child. So my html head section is looking very bad.
Here is a http://jsfiddle.net/Js8DF/ for the complete script. Somebody please tell me how can I get the job done nicely and more elegantly.