Results 1 to 5 of 5

Thread: disable a dropdown

  1. #1
    Join Date
    Nov 2012

    disable a dropdown


    I have an application which uses a dropdown for one of the fields. After making a choice in this dropdown and setting another field, I query a database and return information to the page. When the page has been reset with the info, I need the dropdown, with its selection set, to be disabled, as the user should not beable to change this at this point, as it is a part of the key. I have tried to use document.getElementById('dropdown').disabled = true but no success. Any ideas? Thanks in advance.

  2. #2
    Join Date
    May 2006
    Somewhere behind your screen
    <!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css"></style>
    <script type="text/javascript">
    function sw(){
    var elem=document.getElementById('sel'),btn=document.getElementById('switcher');
    if(!elem.disabled){elem.disabled='disabled';btn.value="Switch it on";}
    else{elem.disabled=false;btn.value="Switch it off";}
    <select id="sel">
    <br /><br />
    <input id="switcher" type="button" value="Switch it off" /><br />
    Last edited by Padonak; 01-16-2013 at 05:37 PM.
    signature under construction

  3. #3
    Join Date
    Nov 2012
    Thank you for the reply Padonak, however, setting the disabled property to disabled did not work either. I am still able to change the selection which is what I need to prevent. I had thought this part would be rather simple, but it has proven to be quite a challenge.

  4. #4
    Join Date
    Nov 2012
    Ok. i figured out why this wasn't working for me. I was missing and = in i < 2, therefore I was not making it to the correct selection and skipping the area where I set it to disabled. Correction made and now it works like a charm.

    Thanks for the help.

  5. #5
    Join Date
    Nov 2012
    should be "missing an ="

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center