[CLOSED] How to call javascript function sending the selected item text from a comboBox?

  1. #1

    [CLOSED] How to call javascript function sending the selected item text from a comboBox?

    Hi,

    Could you tell me please how to call the javascript function AskNed sending the selected item text from the comboBox comboBoxAvatarTopics as parameter?

     var AskNed = function(text) 
     {
         alert(text);
     };
    
            <ext:ComboBox id="comboBoxAvatarTopics" runat="server" StoreID="StoreAvatarTopics" DisplayField="TITLE" 
                              ValueField="ID" Width="387px" Height="21px" FieldLabel="Call Dr. Ned About " 
                              cls="comboBoxAvatarTopics" LabelAlign="Top" Text="<%$ Resources: comboBoxAvatarTopics.Text %>">
                    <Listeners>
                        <Select Handler="AskNed();" />
                    </Listeners>
                </ext:ComboBox>
    Last edited by geoffrey.mcgill; Aug 25, 2010 at 5:41 PM. Reason: [CLOSED]
  2. #2
    Hi,

    You can call .getValue() on any Field type component.

    Example

    <Select Handler="AskNed(this.getValue());" />
    Geoffrey McGill
    Founder
  3. #3
    More information available from the docs, see

    http://dev.sencha.com/deploy/dev/doc...ember=getValue
    Geoffrey McGill
    Founder
  4. #4

    get selected text and selected value

    Dear geoffery

    and please , how can i get selected text and selected value
    Last edited by geoffrey.mcgill; Feb 26, 2014 at 11:18 AM. Reason: formatting
  5. #5
    Here is an example.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.ComboBox1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "1", "Item 1" },
                    new object[] { "2", "Item 2" },
                    new object[] { "3", "Item 3" }
                };
            }
        }
    
        protected void Get(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Value", this.ComboBox1.SelectedItem.Value + " " + this.ComboBox1.SelectedItem.Text).Show();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Button runat="server" Text="Get value and text on server side" OnDirectClick="Get" />
    
            <ext:Button runat="server" Text="Get value and text on client side" Handler="alert(App.ComboBox1.getValue() + ' ' + App.ComboBox1.getRawValue());" />
    
            <ext:ComboBox 
                ID="ComboBox1" 
                runat="server" 
                DisplayField="text" 
                ValueField="value">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="value" />
                                    <ext:ModelField Name="text" />
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Reader>
                            <ext:ArrayReader />
                        </Reader>
                    </ext:Store>
                </Store>
            </ext:ComboBox>
        </form>
    </body>
    </html>
  6. #6
    thank you daniil

    but i mean in client side , like
    <Select Handler="this.getValue();" />
    to get the selected value .
    Last edited by Daniil; Feb 26, 2014 at 9:57 AM. Reason: Please use [CODE] tags
  7. #7
    Example
    <Select Handler="var value = records[0].data[this.valueField],
                         text = records[0].data[this.displayField];" />

Similar Threads

  1. Replies: 3
    Last Post: Oct 27, 2012, 10:47 AM
  2. Call JavaScript function with CellSelection
    By bolzi89 in forum 1.x Help
    Replies: 5
    Last Post: Dec 23, 2011, 2:42 PM
  3. Replies: 3
    Last Post: Aug 21, 2010, 5:26 AM
  4. [CLOSED] Call Javascript Function
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 21, 2010, 3:58 AM
  5. Replies: 10
    Last Post: Apr 05, 2010, 1:42 AM

Posting Permissions