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

how to add the style to the input box dynamically

2 Answers 95 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
lan
Top achievements
Rank 1
lan asked on 13 Oct 2010, 05:15 PM
Hi Telerik,

We use RadComboBox to let our customers to input/choose font family. The idea is when user finish the input/choose,  we try to set the input box font-family equals to what his input, so the user knows what exactly it looks like.

We will use two functions on the client side: OnClientSelectedIndexChanged and OnClientTextChange

but we don't know how to set the style in the client functions.

Please help.

Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 14 Oct 2010, 08:39 AM
Hello Lan,

Try the following code snippet which shows how to set RadComboBox input box fontfamily style from client side.

ASPX:
<telerik:RadComboBox ID="RadComboBox1" runat="server"   
    OnClientSelectedIndexChanged="Changefontstyle"  AllowCustomText="True">
</telerik:RadComboBox>

Java Script:
<script type="text/javascript">
    function Changefontstyle(sender, args) {
      var inputElement = sender.get_inputDomElement();
      inputElement.style.fontFamily = "Courier";//setting fontfamily style
   }
</script>

Thanks,
Princy.
0
lan
Top achievements
Rank 1
answered on 14 Oct 2010, 04:05 PM
Thanks Princy!

That's exactly what I am looking for.  I just changed a little bit in case other people need it.

<script type="text/javascript">

    functionChangefontstyle(sender, args) {

      varinputElement = sender.get_inputDomElement();

      inputElement.style.fontFamily = sender._text;//setting fontfamily style

   }

</script>

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