Copy value as text from 1 combo box to another using js

4 posts, 1 answers
  1. Bill
    Bill avatar
    6 posts
    Member since:
    Sep 2011

    Posted 13 Jun 2012 Link to this post

    Hey all

    I was wondering how you can copy a value as text from one combo box to another (as text on the destination combobox) using javascript, and concatenating additional values as a text string.

    Thanks!
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Jun 2012 Link to this post

    Hi Bill,

    Try the following Javascript to achieve your scenario.

    JS:
    <script type="text/javascript" >
            function OnClientSelectedIndexChanged(sender, args)
            {
                var stateTxt = $find("<%=RadComboBox1.ClientID%>").get_value();
                $find("<%= RadComboBox2.ClientID %>").set_text(stateTxt);
            }
         
    </script>

    Thanks,
    Princy.
  3. Bill
    Bill avatar
    6 posts
    Member since:
    Sep 2011

    Posted 17 Jun 2012 Link to this post

    Princy

    Thanks for the help. I was wondering though: how do you specify the client id for a radcontrol from a javascript inside the master page to a content page? As well, I recall seeing different properties for a radcontrol that are used in javascript on your site. You have a link for that page?

    Thanks again!
    Bill
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Jun 2012 Link to this post

    Hi Bill,

    Try the following code snippet to achieve your scenario. 

    JS:
    <script type="text/javascript" >
            function OnClientClick()
            {
                var txtCont = document.getElementById('<%= Page.Master.FindControl("MainContent").FindControl("RadComboBox1").ClientID %>');
            }
    </script>

    Hope this helps.

    Thanks,
    Princy.
Back to Top