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. Dynamically clear selected items of itembox

Dynamically clear selected items of itembox

Scheduled Pinned Locked Moved ASP.NET
javascriptquestion
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.
  • M Offline
    M Offline
    Member 1086586
    wrote on last edited by
    #1

    How would I add code to the htm below to clear the selected items of one listbox when the focus is put on another listbox? Would I use javascript?

    Size

    5" 6" 7" 8" 9"

    Color

    Red Green Blue Yellow

    Thanks

    H C 2 Replies Last reply
    0
    • M Member 1086586

      How would I add code to the htm below to clear the selected items of one listbox when the focus is put on another listbox? Would I use javascript?

      Size

      5" 6" 7" 8" 9"

      Color

      Red Green Blue Yellow

      Thanks

      H Offline
      H Offline
      Hellin
      wrote on last edited by
      #2

      I don't know your meanning. I think that must use JavaScript. You can control a property of display of the selectlistbox, Or Remove Object and Create Object

      1 Reply Last reply
      0
      • M Member 1086586

        How would I add code to the htm below to clear the selected items of one listbox when the focus is put on another listbox? Would I use javascript?

        Size

        5" 6" 7" 8" 9"

        Color

        Red Green Blue Yellow

        Thanks

        C Offline
        C Offline
        codeajay
        wrote on last edited by
        #3

        Hi Dlugie Try below functions for listbox and submit button The submit button function is written to allow you to check the last focused listbox and it will not remove the selected items text1 is a hidden textbox. Also, plz use id for list boxes or any control you place in your form. What i have seen is that id is much helpful in getting the element than by name. check these corrections: addition: ----------your functions-------------- function lbonfocusout(lb) { if(myform.text1.value=="1") return; myform.all(lb.id).selectedIndex=-1 } function Submit_onbeforeactivate() { myform.text1.value="1"; for(x=0;x

        M 1 Reply Last reply
        0
        • C codeajay

          Hi Dlugie Try below functions for listbox and submit button The submit button function is written to allow you to check the last focused listbox and it will not remove the selected items text1 is a hidden textbox. Also, plz use id for list boxes or any control you place in your form. What i have seen is that id is much helpful in getting the element than by name. check these corrections: addition: ----------your functions-------------- function lbonfocusout(lb) { if(myform.text1.value=="1") return; myform.all(lb.id).selectedIndex=-1 } function Submit_onbeforeactivate() { myform.text1.value="1"; for(x=0;x

          M Offline
          M Offline
          Member 1086586
          wrote on last edited by
          #4

          Thanks for the replies. Maybe I’m not explaining the problem correctly. I have two itemboxes and two radio buttons. I want to clear the selected items (not delete) from the one itembox when focus is set on the other itembox. I was able to partially achieve this with the code below but was not able to completely clear the selected items. P.S --> I'm new to javascript so thanks for your patience and help :) -------------------------------------------------------------- function lbOnFocus(field) { switch (field){ case "lbSize": if (document.myform.rbCriteria[0].checked = true) { document.myform.rbCriteria[1].checked = true; document.myform.lbSize.selectedIndex = null; } else { document.myform.rbCriteria[0].checked = true; } break; case "lbColor": if (document.myform.rbCriteria[1].checked = true) { document.myform.rbCriteria[0].checked = true; document.myform.lbColor.selectedIndex = null; } else { document.myform.rbCriteria[1].checked = true; } break; } } --------------------------------------------------------------

          M 1 Reply Last reply
          0
          • M Member 1086586

            Thanks for the replies. Maybe I’m not explaining the problem correctly. I have two itemboxes and two radio buttons. I want to clear the selected items (not delete) from the one itembox when focus is set on the other itembox. I was able to partially achieve this with the code below but was not able to completely clear the selected items. P.S --> I'm new to javascript so thanks for your patience and help :) -------------------------------------------------------------- function lbOnFocus(field) { switch (field){ case "lbSize": if (document.myform.rbCriteria[0].checked = true) { document.myform.rbCriteria[1].checked = true; document.myform.lbSize.selectedIndex = null; } else { document.myform.rbCriteria[0].checked = true; } break; case "lbColor": if (document.myform.rbCriteria[1].checked = true) { document.myform.rbCriteria[0].checked = true; document.myform.lbColor.selectedIndex = null; } else { document.myform.rbCriteria[1].checked = true; } break; } } --------------------------------------------------------------

            M Offline
            M Offline
            Member 1086586
            wrote on last edited by
            #5

            This is why i'm a novice ;P The following lines: document.myform.lbSize.selectedIndex = null; document.myform.lbColor.selectedIndex = null; should be replaced with: document.myform.lbSize.selectedIndex = -1; document.myform.lbColor.selectedIndex = -1; Thanks for your help..

            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