Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Adding more drop down lists on link click

Adding more drop down lists on link click

Scheduled Pinned Locked Moved ASP.NET
javascriptcomsysadmintutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gottimukkala
    wrote on last edited by
    #1

    I have a drop downlist on server with a list of groups from the logged in user. When the user select a group from the drop down list I have to add a "Remove" link next to this drop down list and anohter link "Add to another group" down to this drop down list. If the clicks on this link then another drop down list with the groups except the one user selected in the above drop down list should be created on top of it. Does any one please tell me, how to do this and I have a sample image of my explanation in this link: http://www.doxtop.com/Browse/3645e617/addtomultiplegroups.aspx?private_key=fca98fbb Here is my code: I could add new drop down list on clicking the "Add another group" link but I need to get the items in the new drop downlist as items- the previous selected item.

    <tr id="trGroups" style="display: none;">
    <td class="tdUpload10">Groups:</td>
    <td id="tdGroups"> <asp:DropDownList ID="ddlGroups" runat="server" CssClass="dropdown1" Width="50%">
    </asp:DropDownList> <a href="" id="lRemovePub" runat="server" class="link1" style="display:none;vertical-align:top">Remove </a>
    <div id="divDDLMore" style="display:none;vertical-align:top">
    </div> <div id="div1" runat="server" style="display:none"> Attached successfully. <a href="" id="A3" runat="server" class="link1">Remove </a></div> </td> </tr>
    <tr id="trMoreGroups" style="display:none;vertical-align:top" runat="server">
    <td>   </td> <td>
    <a href="" id="lMoreGroup" runat="server" class="link1" onclick="AddToMoreGroups()">Add to another group</a> </td> </tr>

    Here is my javascript code: function AddToMoreGroups() { var tdGroups = document.getElementById(tdGroups); var ddlGroupId = document.getElementById(ddlGroupsId); var trMoreGroups = document.getElementById(trMoreGroupsId); var ddlGroups = ''; ddlGroups += '<select class=\"dropdown1\" style=\"width:50%\" id=\"ddlGroups\" runat=\"server\">'; var groupsArray = allGroups.split(';'); if(groupsArray != '') { ddlGroups += "<option value = '" +emptyGroup +"'>Select Group...</option>" for(var i =0; i <groupsArray.length; i++) {

    C 1 Reply Last reply
    0
    • G gottimukkala

      I have a drop downlist on server with a list of groups from the logged in user. When the user select a group from the drop down list I have to add a "Remove" link next to this drop down list and anohter link "Add to another group" down to this drop down list. If the clicks on this link then another drop down list with the groups except the one user selected in the above drop down list should be created on top of it. Does any one please tell me, how to do this and I have a sample image of my explanation in this link: http://www.doxtop.com/Browse/3645e617/addtomultiplegroups.aspx?private_key=fca98fbb Here is my code: I could add new drop down list on clicking the "Add another group" link but I need to get the items in the new drop downlist as items- the previous selected item.

      <tr id="trGroups" style="display: none;">
      <td class="tdUpload10">Groups:</td>
      <td id="tdGroups"> <asp:DropDownList ID="ddlGroups" runat="server" CssClass="dropdown1" Width="50%">
      </asp:DropDownList> <a href="" id="lRemovePub" runat="server" class="link1" style="display:none;vertical-align:top">Remove </a>
      <div id="divDDLMore" style="display:none;vertical-align:top">
      </div> <div id="div1" runat="server" style="display:none"> Attached successfully. <a href="" id="A3" runat="server" class="link1">Remove </a></div> </td> </tr>
      <tr id="trMoreGroups" style="display:none;vertical-align:top" runat="server">
      <td>   </td> <td>
      <a href="" id="lMoreGroup" runat="server" class="link1" onclick="AddToMoreGroups()">Add to another group</a> </td> </tr>

      Here is my javascript code: function AddToMoreGroups() { var tdGroups = document.getElementById(tdGroups); var ddlGroupId = document.getElementById(ddlGroupsId); var trMoreGroups = document.getElementById(trMoreGroupsId); var ddlGroups = ''; ddlGroups += '<select class=\"dropdown1\" style=\"width:50%\" id=\"ddlGroups\" runat=\"server\">'; var groupsArray = allGroups.split(';'); if(groupsArray != '') { ddlGroups += "<option value = '" +emptyGroup +"'>Select Group...</option>" for(var i =0; i <groupsArray.length; i++) {

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If you're adding them on the client, they won't appear in viewstate, but they will appear in the form that gets posted back to the server.

      Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

      G 1 Reply Last reply
      0
      • C Christian Graus

        If you're adding them on the client, they won't appear in viewstate, but they will appear in the form that gets posted back to the server.

        Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

        G Offline
        G Offline
        gottimukkala
        wrote on last edited by
        #3

        As you can see in my code I could store the selected groupIds in a variable and add the items by checking these groupIds. I have another problem here. I created my other drop down lists on client side using javascript and all the html code for the to a but on the JS side if i want to get the items I am popping up with the javascript error. Here the first line is breaking. Can't get the items of my drop down list created on client side. for(var i=0; i < ddlGroups.options.length; i++) { if(ddlGroups.options[i].selected == true) { grId = ddlGroups.options[i].value; break; } }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups