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. Drop Down List

Drop Down List

Scheduled Pinned Locked Moved Web Development
javascriptquestion
6 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
    Goodway
    wrote on last edited by
    #1

    Hi everyone, I have an aspx page, in this aspx page I have a drop down list, I want to set this drop down list to Read only so the user can't change the selected value, I want to set this drop down list to Read only in Javascript and not using the code behind, what property should I use?? Thanks.

    G 1 Reply Last reply
    0
    • G Goodway

      Hi everyone, I have an aspx page, in this aspx page I have a drop down list, I want to set this drop down list to Read only so the user can't change the selected value, I want to set this drop down list to Read only in Javascript and not using the code behind, what property should I use?? Thanks.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      There is no read only property for the select element. You can set the disabled property to true, which is similar to read only. The field will not be included when you post the form, though. --- b { font-weight: normal; }

      G 1 Reply Last reply
      0
      • G Guffa

        There is no read only property for the select element. You can set the disabled property to true, which is similar to read only. The field will not be included when you post the form, though. --- b { font-weight: normal; }

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

        Thanks, I used the disabled property. Now I want to hide the first two elements in the drop down list, how can I do that using javascript. thanks again.

        G 1 Reply Last reply
        0
        • G Goodway

          Thanks, I used the disabled property. Now I want to hide the first two elements in the drop down list, how can I do that using javascript. thanks again.

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          In what way do you want to hide them? Do you want to remove them? document.FormName.FieldName.options[1] = null; document.FormName.FieldName.options[0] = null; --- b { font-weight: normal; }

          G 1 Reply Last reply
          0
          • G Guffa

            In what way do you want to hide them? Do you want to remove them? document.FormName.FieldName.options[1] = null; document.FormName.FieldName.options[0] = null; --- b { font-weight: normal; }

            G Offline
            G Offline
            Goodway
            wrote on last edited by
            #5

            Thanks Guffa but I don't want to remove them, depending on a radio button choice, I want to hide the first two elements. If the user select another radio button I want to show these 2 elements, How can this be done in Javascript? thanks again.

            G 1 Reply Last reply
            0
            • G Goodway

              Thanks Guffa but I don't want to remove them, depending on a radio button choice, I want to hide the first two elements. If the user select another radio button I want to show these 2 elements, How can this be done in Javascript? thanks again.

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              There is no way of hiding options. If you don't want them to apperar in the list you have to remove them from the options collection, and then add them again if needed. --- b { font-weight: normal; }

              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