This is a migrated thread and some comments may be shown as answers.

help in javascript

1 Answer 60 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
sadiqabbas
Top achievements
Rank 1
sadiqabbas asked on 15 Apr 2009, 07:50 PM
actually i am a newbie and need some help

in radcombobox i am trying to do below things but not success

<script type="text/javascript">
function calc(sender,args)
{
var footer = sender._getFooterElement();
footer.innerHTML = args.get_item().get_text();
}
</script>
<radcombobox id=rcb1 .......... onclientselectedindexchanged=calc>

actually i want to display selected value of combo box in a label without loading whole page
i mean text1,text2,text3 are stored in combo box then when user changes combo box value to text3 then label's value should change to text3

as i am a newbie here
and sorry for bad english

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Apr 2009, 06:19 AM

Hello,

The code that you used is for setting the text of label which is placed in FooterTemplate of RadComboBox on changing the selection. I tried your code and it is working fine in my end (works only if you add FooterTemplate).

If you are trying to set the selected item text to label outside the RadCombobox, then you can try following code for that.

aspx:

 
<telerik:radcombobox id="RadComboBox1" runat="server" OnClientSelectedIndexChanged="calc">  
<FooterTemplate> 
<asp:Label ID="LabelFooter" Text="Text" runat="server"></asp:Label> 
</FooterTemplate> 
<Items> 
<telerik:RadComboBoxItem runat="server" Text="Item1" Value="Item1"></telerik:RadComboBoxItem> 
<telerik:RadComboBoxItem runat="server" Text="Item2" Value="Item2"></telerik:RadComboBoxItem> 
<telerik:RadComboBoxItem runat="server" Text="Item3" Value="Item3"></telerik:RadComboBoxItem> 
</Items> 
</telerik:radcombobox> 
 
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 

javascript:

 
<script type="text/javascript">  
function calc(sender,args)  
{  
    var footer = sender._getFooterElement();  //Accessing the label in footer of RadComboBox  
    footer.innerHTML = args.get_item().get_text(); //Setting the text of footer  
      
    var label = document.getElementById("Label1"); // Access the label with id 'Label1'  
    label.innerText  = args.get_item().get_text(); // Set the text of label  
}  
</script> 

I believe the links below will be helpful to you;
Client-Side Basics
Client-Side Events

Thanks,
Princy.

Tags
ComboBox
Asked by
sadiqabbas
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or