Hi I am pretty simple in jQuery and stuck in a script:
//hide all radio buttons first $('#q11_6_1').parent().hide(); $('#q11_6_2').parent().hide(); $('#q11_6_3').parent().hide(); $('#q11_6_4').parent().hide(); $('#q11_6_5').parent().hide(); //check the length of the open text box var other2text = $('#q11_6_other').val().length; $('#q11_6_other').keypress(function(){ //if at least one character has been entered, then I want to show all radio buttons if(other2text>=0) { $('#q11_6_1').parent().show(); $('#q11_6_2').parent().show(); $('#q11_6_3').parent().show(); $('#q11_6_4').parent().show(); $('#q11_6_5').parent().show(); } //else I want to hide all else { $('#q11_6_1').parent().hide(); $('#q11_6_2').parent().hide(); $('#q11_6_3').parent().hide(); $('#q11_6_4').parent().hide(); $('#q11_6_5').parent().hide(); } });
The first part of the "if condition" works, however, when I cleared all the texts in q11_6_other, these switches will not hide. I think the else section is not working, but not sure how to get around it.
Thanks so much with your help !!!
source share