I have a Java form where I need to be able to switch a drop down with a text box using Javascript. The change would be made depending on the radio button choice the user makes. The drop down is the default form element and radio button A is checked by default. So when the user clicks radio button B the text box should appear and if they change their mind and select radio button A the drop down should come back.

Whats making this a little tricky is that I'm doing my form validation using Java via the form element name. So these two will have the same name. I need for the drop down to be switched off/disabled if they have radio button B and vice versa.

Is all this doable using javascript?

Recommended Answers

All 3 Replies

Yes this is doable using javascript, add an id parameter to the drop downs then on the javascript function call the id's, there are loads of examples to disable and enable an element on the internet to help u along as well. you can also look into using jquery, makes it much easier, no need to actually code anything just call the function.

Thanks Thirusha, will look into doing this using JQuery.

my pleasure :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.