radioButtonList选择的值显示在文本框上 [英] radioButtonList selected value to show on textbox

查看:111
本文介绍了radioButtonList选择的值显示在文本框上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个单选按钮列表和一个文本框.
我想从每个单选按钮列表中选择一个值,并在文本框中显示该值.您可以使用以下代码:

  var  rblSelectType = document.getElementById(' ;
txtSelectedItem = document.getElementById('  hdntxtTextbox').;
 var  rbtnOne = rblSelectType + '  _ 0' ;
 var  rbtnTwo = rblSelectType + '  _ 1' ;
 var  rbtnThree = rblSelectType + '  _ 3' ;
如果(document.getElementById(rbtnOne).已选中){
    txtSelectedItem. = "  ;
}
其他 如果(document.getElementById(rbtnTwo).选中){
    txtSelectedItem. = "  ;
}
其他 如果(document.getElementById(rbtnThree).已选中){
    txtSelectedItem. = "  ;
} 



hdnRbtnList-将成为您的RadiobuttonList ClientID
hdntxtTextbox-将是您的TextBox ClientID

希望对您有所帮助.


嘿,

您在寻找这个吗?...

 textbox1.text = radiobuttonlist.selectedvalue.tostring()


 
{

   如果(Rb.Checked)
   {

    textBox1.Text = Rb.Text;

   }

} 


i have 3 radio button list and a text box.
i want to select value from each radio button list and show the value in textbox.

解决方案

If you are trying to do this in Javascript. You can use the following code :

var rblSelectType = document.getElementById('hdnRbtnList').value;
txtSelectedItem = document.getElementById('hdntxtTextbox').value;
var rbtnOne = rblSelectType + '_0';
var rbtnTwo = rblSelectType + '_1';
var rbtnThree = rblSelectType + '_3';
if (document.getElementById(rbtnOne).checked) {
    txtSelectedItem.value = "Your Value";
}
else if (document.getElementById(rbtnTwo).checked) {
    txtSelectedItem.value = "Your Value";
}
else if (document.getElementById(rbtnThree).checked) {
    txtSelectedItem.value = "Your Value";
}



hdnRbtnList - will be your RadiobuttonList ClientID
hdntxtTextbox - will be your TextBox ClientID

Hope this helps.


hey,

R u looking for this....

textbox1.text= radiobuttonlist.selectedvalue.tostring()


foreach(RadioButton Rb in radiobtnlist.Controls.OfType<RadioButton>())
{

   if(Rb.Checked)
   {

    textBox1.Text = Rb.Text;

   }

}


这篇关于radioButtonList选择的值显示在文本框上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆