Text Box to Appear When a Radio Button Is Selected

Text box to appear when a radio button is selected

Try this:

function ShowHideDiv() {        var chkYes = document.getElementById("chkYes");        var dvtext = document.getElementById("dvtext");        dvtext.style.display = chkYes.checked ? "block" : "none";    }
<label for="chkYes">    <input type="radio" id="chkYes" name="chk" onclick="ShowHideDiv()" />    Yes</label><label for="chkNo">    <input type="radio" id="chkNo" name="chk" onclick="ShowHideDiv()" />    No</label><div id="dvtext" style="display: none">    Text Box:    <input type="text" id="txtBox" /></div>

Hide/display of 3 textboxes on selection of radio button

You could do this as follows. First change your HTML to this:

<input type="radio" name="type" value="Fresher"> Fresher
<input type="radio" name="type" value="Experienced"> Experienced

<div id="textboxes" style="display: none">
Company Name: <input type="text" hidden="true"/>
Designation: <input type="text" hidden="true"/>
Year_of_Experience: <input type="text" hidden="true"/>
</div>

What this code adds to your code is to have a value for the radio buttons. This allows us to make a selection based on which radio button was selected. Secondly, the input fields are grouped together in a <div> to allow for easy hiding of the three input fields. After you have modifief your HTML as such, include jQuery on your website and use this code:

$(function() {
$('input[name="type"]').on('click', function() {
if ($(this).val() == 'Experienced') {
$('#textboxes').show();
}
else {
$('#textboxes').hide();
}
});
});

You can see how this works using this JSFiddle: http://jsfiddle.net/pHsyj/

display textboxes when radio button selected

try this code

$(document).ready(function() {
$(this).click(function() { $('#textbox').html(''); var val = $('input[name=accompanying_person]:checked').val(); for (var i = 1; i <= val; i++) { $('#textbox').append('<input type="text" id="' + i + '"><br>'); } });});
input {  margin-bottom: 3px;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div>  <label for="accompanying_person" class="col-sm-4 col-form-label">Select number of accompanying person</label>  <div class="col-sm-8">    <input type="radio" name="accompanying_person" id="accompanying_person" value="1"> 1    <input type="radio" name="accompanying_person" id="accompanying_person" value="2"> 2    <input type="radio" name="accompanying_person" id="accompanying_person" value="3"> 3
</div> <div id="textbox"></div></div>

If radio button is checked, display a text box in Java

I'm not sure of your experience level with android studio, so I'm going to assume you know how to use OnClickListeners. If not, check out this tutorial. https://www.youtube.com/watch?v=01gOTzT2v-0

Rather than creating a TextView on a click, try having an empty TextView, and then simply change the text inside. Try using this method for your onClick:

public void onClick(View view) {
boolean checked = ((RadioButton) view).isChecked();

switch(view.getId()) {
case R.id.button1:
if (checked)
findViewById(R.id.textView).setText("Button1 has been chosen");
break;
case R.id.button2:
if (checked)
findViewById(R.id.textView).setText("Button2 has been chosen");
break;
}
}

You'll have to change the "R.id.something" to the appropriate ids. I trust you'll be able to use the method, or use the useful parts. Hope I helped!

show hide text box based on selection of radio button

I got the solution. I just need to create 2 div. 1 div has 1 text box and another div is 2 text box. And just make show/hide control for these 2 div.Thanks

Fill Textbox when Radio button is selected - Visual Studio - Windows Form

Assuming that you have a radiobutton with the value on radiobutton text in your UI, add the event CheckedChanged to your radio buttons.

private void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
if (RadioButton1.Checked) //If checked == true
{
textBox1.Text = "12";
//example
}
}


Related Topics



Leave a reply



Submit