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. Urgent Listbox to listbox by using javascript

Urgent Listbox to listbox by using javascript

Scheduled Pinned Locked Moved ASP.NET
javascriptdatabase
5 Posts 3 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.
  • J Offline
    J Offline
    jayarajmrj
    wrote on last edited by
    #1

    I have two listboxes ,one of the listbox data is populate in database. And I have two buttons Add and Remove. Once I click the add the button , the selected items is populated in another list box by using Javascript. Similarly Remove also. Give the javascript code or suitable link for the above scenrio

    V C 2 Replies Last reply
    0
    • J jayarajmrj

      I have two listboxes ,one of the listbox data is populate in database. And I have two buttons Add and Remove. Once I click the add the button , the selected items is populated in another list box by using Javascript. Similarly Remove also. Give the javascript code or suitable link for the above scenrio

      V Offline
      V Offline
      varshavmane
      wrote on last edited by
      #2

      Use the Following code: function f_optionMove(s_from, s_to) { var e_from = document.getElementById(s_from), e_to = document.getElementById(s_to);//test_form.elements[s_from],e_to = document.forms['test_form'].elements[s_to]; if (!e_from.name) return alert ("Error: selectbox with name '" + s_from + "' can't be found."); if (!e_to.name) return alert ("Error: selectbox with name '" + s_from + "' can't be found."); var n_moved = 0; for (var i = 0; i < e_from.options.length; i++) { if (e_from.options[i].selected) { var name = e_from.options[i].text; var ID = e_from.options[i].value; e_from.options[i] = null; e_to.options[e_to.options.length] = new Option (name,ID); n_moved++; } } if (n_moved) e_from.options.length = e_from.options.length; else alert("You haven't selected any options"); } function f_optionMoveAll(s_from, s_to) { var e_from = document.getElementById(s_from), e_to = document.getElementById(s_to); if (!e_from.name) return alert ("Error: selectbox with name '" + s_from + "' can't be found."); if (!e_to.name) return alert ("Error: selectbox with name '" + s_from + "' can't be found."); var cntDesc = e_from.options.length; var cntSource = e_to.options.length; for (var i = 0; i < cntDesc; i++) { var name = e_from.options[i].text; var ID = e_from.options[i].value; e_to.options[cntSource] = new Option (name,ID); cntSource++; } e_from.options.length = 0; } < table border="0" cellpadding="0" cellspacing="0" style="width: 100%">

      J 1 Reply Last reply
      0
      • V varshavmane

        Use the Following code: function f_optionMove(s_from, s_to) { var e_from = document.getElementById(s_from), e_to = document.getElementById(s_to);//test_form.elements[s_from],e_to = document.forms['test_form'].elements[s_to]; if (!e_from.name) return alert ("Error: selectbox with name '" + s_from + "' can't be found."); if (!e_to.name) return alert ("Error: selectbox with name '" + s_from + "' can't be found."); var n_moved = 0; for (var i = 0; i < e_from.options.length; i++) { if (e_from.options[i].selected) { var name = e_from.options[i].text; var ID = e_from.options[i].value; e_from.options[i] = null; e_to.options[e_to.options.length] = new Option (name,ID); n_moved++; } } if (n_moved) e_from.options.length = e_from.options.length; else alert("You haven't selected any options"); } function f_optionMoveAll(s_from, s_to) { var e_from = document.getElementById(s_from), e_to = document.getElementById(s_to); if (!e_from.name) return alert ("Error: selectbox with name '" + s_from + "' can't be found."); if (!e_to.name) return alert ("Error: selectbox with name '" + s_from + "' can't be found."); var cntDesc = e_from.options.length; var cntSource = e_to.options.length; for (var i = 0; i < cntDesc; i++) { var name = e_from.options[i].text; var ID = e_from.options[i].value; e_to.options[cntSource] = new Option (name,ID); cntSource++; } e_from.options.length = 0; } < table border="0" cellpadding="0" cellspacing="0" style="width: 100%">

        J Offline
        J Offline
        jayarajmrj
        wrote on last edited by
        #3

        how can i store the values in the 'lstdestination' listbox. Suppose i select the three values from the lstsource. How can i reterive the three values in server side ie., Code behind.

        V 1 Reply Last reply
        0
        • J jayarajmrj

          how can i store the values in the 'lstdestination' listbox. Suppose i select the three values from the lstsource. How can i reterive the three values in server side ie., Code behind.

          V Offline
          V Offline
          varshavmane
          wrote on last edited by
          #4

          What is the exact functionality u want, please explain that so that I can give u the proper suggestion.

          1 Reply Last reply
          0
          • J jayarajmrj

            I have two listboxes ,one of the listbox data is populate in database. And I have two buttons Add and Remove. Once I click the add the button , the selected items is populated in another list box by using Javascript. Similarly Remove also. Give the javascript code or suitable link for the above scenrio

            C Offline
            C Offline
            codelinks
            wrote on last edited by
            #5

            hi found this in codeproject http://www.codeproject.com/useritems/Listbox\_or\_combo\_box.asp

            winnie

            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