RichDropdown get selected value in javascript

Last post 05-05-2006, 12:07 AM by VikasJoshi. 8 replies.
Sort Posts: Previous Next
  •  09-30-2005, 5:09 AM 11227

    RichDropdown get selected value in javascript

    Hi

    I need to get the selected value of an richDropdown which contains a tree.
    The call must be javascript cause i need the value in a javascript function triggerd by a button

    Please help soon.
    We need it badly

    Greetings

    Marc Gerritsen
    Topicus
  •  09-30-2005, 12:32 PM 11239 in reply to 11227

    Re: RichDropdown get selected value in javascript

    Topicus,
     
    Here is the code:
     
    // get the cute editor instance
    var editor1 = document.getElementById('CE_Editor1_ID');

    if(editor.all)
    {
        var lis=editor.all.tags("LI");
          for(var i=0;i<lis.length;i++)
          {
               var item=lis.item(i);
               if(item._IsTreeDropDown=="True")
               {
                //put your code here        
               }
          }
    }
        

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  10-17-2005, 5:22 AM 11762 in reply to 11239

    Re: RichDropdown get selected value in javascript

    editor.all.tags("LI"); does not return any items so the for loop exits immediately.

    I am using CuteEditor For .Net version 5.0
  •  10-17-2005, 7:23 PM 11774 in reply to 11762

    Re: RichDropdown get selected value in javascript

    Sorry, it should be:
     
     
    Here is the code:
     
    // get the cute editor instance
    var editor1 = document.getElementById('CE_Editor1_ID');
    var editor = document.getElementById('CE_Editor1_ID');

    if(editor.all)
    {
        var lis=editor.all.tags("LI");
          for(var i=0;i<lis.length;i++)
          {
               var item=lis.item(i);
               if(item._IsTreeDropDown=="True")
               {
                //put your code here        
               }
          }
    }

     


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  10-18-2005, 3:29 AM 11788 in reply to 11774

    Re: RichDropdown get selected value in javascript

    I did already notice that typo. The TreeListComponent is being created programmatically in C# like this:

    TreeDropDownList tree = (TreeDropDownList)toolControlInsertVeldDLL.Control;
    tree.ID = "tree_id";
    IList berichtveldCategorieeen = TussenpersoonDAO.LoadBerichtVeldCategorieen();

    foreach (BerichtVeldCategorie bvc in berichtveldCategorieeen)
    {
         TreeListItem tli = new TreeListItem(bvc.Omschrijving);
         tli.Selectable = false;
         FillBerichtVeldCategorie(tli, bvc);
         tree.Items.Add(tli);
    }
    tree.Attributes.Remove("onclick");
    tree.Attributes.Remove("onchange");

    private void FillBerichtVeldCategorie(TreeListItem rootTLI, BerichtVeldCategorie rootBVC)
    {
         if(rootBVC.SubCategorieen.Count > 0)
         {
               foreach (BerichtVeldCategorie categorie in rootBVC.SubCategorieen)
              {
                    TreeListItem subCategorieTLI = new TreeListItem(categorie.Omschrijving, categorie.Id.ToString());
                    subCategorieTLI.Selectable = false;
                    FillBerichtVeldCategorie(subCategorieTLI, categorie);
                    rootTLI.Items.Add(subCategorieTLI);
               }
          }
          else
          {
               foreach(BerichtVeld berichtVeld in rootBVC.BerichtVelden)
               {
                    string value = berichtVeld.Id.ToString() + "~" + berichtVeld.Omschrijving;
                    TreeListItem berichtVeldTLI = new TreeListItem(berichtVeld.Naam, value);
                     rootTLI.Items.Add(berichtVeldTLI);
                }
           }           
     }
  •  10-20-2005, 11:02 AM 11879 in reply to 11774

    Re: RichDropdown get selected value in javascript

    var editor1 = document.getElementById('CE_Editor1_ID');
    var editor = document.getElementById('CE_Editor1_ID');

    if(editor.all)
    {
        var lis=editor.all.tags("LI");
    <--- this return a zero length list. So our code does not run. The length is also zero when an
                                                       item is selected from the list. Trying different way of writing LI, li , Li does not help.

          for(var i=0;i<lis.length;i++)
          {
               var item=lis.item(i);
               if(item._IsTreeDropDown=="True")
               {
                //put your code here        
               }
          }
    }

    Could you please help?
  •  10-20-2005, 12:13 PM 11880 in reply to 11879

    Re: RichDropdown get selected value in javascript

    Please use the following code:
     
        // get the cute editor instance
        var editor1 = document.getElementById('<%=Editor1.ClientID%>');
        
        // Get the editor HTML
        var lis=editor1.getElementsByTagName("LI");
        for(var i=0;i<lis.length;i++)
        {
         var item=lis.item(i);
         if(item._IsTreeDropDown=="True")
         {
          //put your code here 
          alert(item.innerHTML);     
         }
        }
     
     
    Demo is here:
     
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  10-31-2005, 7:07 AM 12126 in reply to 11880

    Re: RichDropdown get selected value in javascript

    I have found my problem with getting no items. The Id in GetElementById should have been CE_<editor_id>_ID, where I was trying to access it with <editor_id>.

    Now I have a new problem. The Item that is found it the entire dropdowntree and I would like to only get the the selected TreeItem. The DropDownTree consists of two levels (level one are groupheading and level two are the selectable items).

    The example on http://cutesoft.net/example/JavaScript-TREE.aspx does nothing with the tree item. When I click the button nothing happens.
  •  05-05-2006, 12:07 AM 18848 in reply to 12126

    Re: RichDropdown get selected value in javascript

    Hi ,


    The same thing I require but that was for the dropdown and I want the selected Item Index or text or Value.

    Please let me know for that.


    Vikas Joshi
View as RSS news feed in XML