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. ASP.NET Listbox and javascript?

ASP.NET Listbox and javascript?

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-netdatabasehelp
9 Posts 5 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.
  • R Offline
    R Offline
    R Thomas 0
    wrote on last edited by
    #1

    actually what i want to do is that i have two list boxes. when i click any one one a particular item, the other listbox's same idex item should get highlighted too.. producing a list of listview effect ie. whenever an item is clicked on either of the listboxes, the sames index item on the other listbox will get highlighted too.. to test this i made the below code to see how to integrate javascript in asp.NET i made a list box and added a javascript function to it i made the listbox i added a javascript event to it on PageLoad lstFilter.Attributes.Add("onchange", "SelectPair(window.document.form1.lstFilter.options[selectedIndex].text);") then i wrote the javascript function : function SelectPair(window.document.form1.lstFilter.options[selectedIndex].text) { //lstvalue.select( window.document.Form1.lstFilter.options[selectedIndex].text = "hahahah" } but nothing is working....can u pls help.... tks a lot... "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

    S A 2 Replies Last reply
    0
    • R R Thomas 0

      actually what i want to do is that i have two list boxes. when i click any one one a particular item, the other listbox's same idex item should get highlighted too.. producing a list of listview effect ie. whenever an item is clicked on either of the listboxes, the sames index item on the other listbox will get highlighted too.. to test this i made the below code to see how to integrate javascript in asp.NET i made a list box and added a javascript function to it i made the listbox i added a javascript event to it on PageLoad lstFilter.Attributes.Add("onchange", "SelectPair(window.document.form1.lstFilter.options[selectedIndex].text);") then i wrote the javascript function : function SelectPair(window.document.form1.lstFilter.options[selectedIndex].text) { //lstvalue.select( window.document.Form1.lstFilter.options[selectedIndex].text = "hahahah" } but nothing is working....can u pls help.... tks a lot... "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

      S Offline
      S Offline
      Spanky3
      wrote on last edited by
      #2

      Like This? I just put this page together for you. Is this the kind of thing you are looking for? Atul

      N R 2 Replies Last reply
      0
      • S Spanky3

        Like This? I just put this page together for you. Is this the kind of thing you are looking for? Atul

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        Spanky3 wrote: I just put this page together for you. Is this the kind of thing you are looking for? Of course this is what he's looking for. Ask the question enough times and someone will do the work for him.

        A 1 Reply Last reply
        0
        • N Not Active

          Spanky3 wrote: I just put this page together for you. Is this the kind of thing you are looking for? Of course this is what he's looking for. Ask the question enough times and someone will do the work for him.

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          it took 30 seconds to do i want my 30 seconds back! ;P only kidding :)

          1 Reply Last reply
          0
          • S Spanky3

            Like This? I just put this page together for you. Is this the kind of thing you are looking for? Atul

            R Offline
            R Offline
            R Thomas 0
            wrote on last edited by
            #5

            but i cant view the aspx code... only the javascript... i wanted to learn about calling the javascript from aspx page.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

            A 1 Reply Last reply
            0
            • R R Thomas 0

              but i cant view the aspx code... only the javascript... i wanted to learn about calling the javascript from aspx page.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

              A Offline
              A Offline
              Anonymous
              wrote on last edited by
              #6

              Okey firstly you can never see asp,php,aspx code as this is the code the server uses to generate the pages. To create that page which i made. I simple dragged 2 drop down list boxes on a form... binded a an sql table and then set the event handler for "selection changed" and synchronised the selected index's ==================================== I dont understand what you mean about the calling javascript from the aspx page. aspx writes some javascript for the controls.

              R 1 Reply Last reply
              0
              • A Anonymous

                Okey firstly you can never see asp,php,aspx code as this is the code the server uses to generate the pages. To create that page which i made. I simple dragged 2 drop down list boxes on a form... binded a an sql table and then set the event handler for "selection changed" and synchronised the selected index's ==================================== I dont understand what you mean about the calling javascript from the aspx page. aspx writes some javascript for the controls.

                R Offline
                R Offline
                R Thomas 0
                wrote on last edited by
                #7

                i know i cant see that code...what i mean is can u paste the code here??:doh: "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

                1 Reply Last reply
                0
                • R R Thomas 0

                  actually what i want to do is that i have two list boxes. when i click any one one a particular item, the other listbox's same idex item should get highlighted too.. producing a list of listview effect ie. whenever an item is clicked on either of the listboxes, the sames index item on the other listbox will get highlighted too.. to test this i made the below code to see how to integrate javascript in asp.NET i made a list box and added a javascript function to it i made the listbox i added a javascript event to it on PageLoad lstFilter.Attributes.Add("onchange", "SelectPair(window.document.form1.lstFilter.options[selectedIndex].text);") then i wrote the javascript function : function SelectPair(window.document.form1.lstFilter.options[selectedIndex].text) { //lstvalue.select( window.document.Form1.lstFilter.options[selectedIndex].text = "hahahah" } but nothing is working....can u pls help.... tks a lot... "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

                  A Offline
                  A Offline
                  Alvaro Mendez
                  wrote on last edited by
                  #8

                  Joseph, 1. Your function is prototyped wrong. It should read something like this:

                  function SelectPair(text)
                  {
                  ....
                  }

                  2. Have you tried doing this instead?

                  lstFilter.Attributes.Add("onchange", "document.form1.otherFilter.selectedIndex = document.form1.lstFilter.selectedIndex");

                  Regards, Alvaro


                  "I do" is both the shortest and the longest sentence in the English language.

                  R 1 Reply Last reply
                  0
                  • A Alvaro Mendez

                    Joseph, 1. Your function is prototyped wrong. It should read something like this:

                    function SelectPair(text)
                    {
                    ....
                    }

                    2. Have you tried doing this instead?

                    lstFilter.Attributes.Add("onchange", "document.form1.otherFilter.selectedIndex = document.form1.lstFilter.selectedIndex");

                    Regards, Alvaro


                    "I do" is both the shortest and the longest sentence in the English language.

                    R Offline
                    R Offline
                    R Thomas 0
                    wrote on last edited by
                    #9

                    Alvaro Mendez wrote: 1. Your function is prototyped wrong. It should read something like this: function SelectPair(text) { ....} yea i did...doesnt affect anything... Alvaro Mendez wrote: . Have you tried doing this instead? lstFilter.Attributes.Add("onchange", "document.form1.otherFilter.selectedIndex = document.form1.lstFilter.selectedIndex"); yea.... doest work either.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

                    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