+ 10

How to keep the HTML text field hidden until a condition is met, e.g until the selection of a radio button.

I want to display a text field based on the selection of the radio button by the user. I know how to do it using AJAX, but I don't want to do it that way. So is there any other way?

23rd Apr 2017, 4:35 PM
Saumya
Saumya - avatar
5 ответов
+ 6
You can do this in many ways. The most simple one would be to use Javascript to alter the css for the text, or you could do this by using DOM-events. I would recommend doing this with DOM-events because it gives a better structure. What you need to do is give some blank text either a class or an ID, and then use javascript to check which button is selected. Then simply change the blank text to whatever you want.
23rd Apr 2017, 4:50 PM
Roolin
Roolin - avatar
+ 18
in asp.net set textbox visibility false and then code section if(radiobutton1.checked) { textbox1.visible="true"; textbox1.text="sololearn is awesome"; }
1st May 2017, 8:45 AM
Krishna Kumar
Krishna Kumar - avatar
+ 9
The problem is I don't know Jquery. So I found using JavaScript to alter css more suitable for me. Thanks everyone for answering.
24th Apr 2017, 12:30 PM
Saumya
Saumya - avatar
+ 4
Use jQuery, is simple and clean $( ".target" ).hide(); $( ".target" ).show();
23rd Apr 2017, 4:54 PM
⏩▶Clau◀⏪
⏩▶Clau◀⏪ - avatar
+ 3
use jQuery instead.
23rd Apr 2017, 4:40 PM
Raj Sharma