stupid getElementById

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darkdirk1
    New Member
    • Oct 2006
    • 50

    stupid getElementById

    I have a bunch of input elements which are DISABLED="true" .
    Based on certain actions I want to enable them using javascript.
    It would be simple to just do this by accessing their names directly, unfortunately this page is a bit more complex. I have it split into DIVs and am making copious usage of style.display=" none"....Also some of the names are common.
    Only the element ID's are definetly unique.
    What I am (basically) trying to do is simply:
    Code:
    var tbl_type_h = document.getElementById("tbl_type_h");
    tbl_type_h.disabled="false";
    But the silly element is still disabled.
    I am sure the function is firing and the correct value is being passed on down.
    It would appear I am not using tbl_type_h correctly.

    Thanks to you who can get me back on track!!!!!
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    You can't blame this on a stupid getElementById, because it is your own fault.
    Question: what do you want to assign to your variable? Answer: the value of the element. Then code it like that:
    [html]var tbl_type_h = document.getEle mentById("tbl_t ype_h").value;[/html]

    Ronald :cool:

    Comment

    • darkdirk1
      New Member
      • Oct 2006
      • 50

      #3
      hehheh... thanks.

      Comment

      • darkdirk1
        New Member
        • Oct 2006
        • 50

        #4
        Darn - i had hoped it was that simple.
        Unfortunately this is not the solution.
        Consider i am actually trying to create an identifier to that page element.
        Not nessecarily caring about the value of the input itself.
        I am using getElementById successfully to control the display property with the syntax shown above - it's only when trying to access the DISABLED prop that I recieve unexpected results...

        Comment

        • darkdirk1
          New Member
          • Oct 2006
          • 50

          #5
          i just went through and made the input names unique.
          Access it the old fashioned way.

          Comment

          • darkdirk1
            New Member
            • Oct 2006
            • 50

            #6
            Originally posted by darkdirk1
            i just went through and made the input names unique.
            Access it the old fashioned way.
            This raises new challenges...
            Any other observartions are much appreciated.

            Comment

            • darkdirk1
              New Member
              • Oct 2006
              • 50

              #7
              Im going to try to accomplish my goal using the form elements index.

              Comment

              • steven
                New Member
                • Sep 2006
                • 143

                #8
                Give this a try:

                Code:
                document.getElementById("tbl_type_h").disabled = "false";

                Comment

                • darkdirk1
                  New Member
                  • Oct 2006
                  • 50

                  #9
                  I ended up giving the elements unique names and adding a hidden input with no value. Then when the user is navigating he forces value to the hidden input.
                  Which I then detect with vbscript and process the appropriate vars based on that value....

                  Which got me by and onto the next screen.

                  Comment

                  • scripto
                    New Member
                    • Oct 2006
                    • 143

                    #10
                    Darkdirk

                    the correct statment should be:

                    var tbl_type_h = document.getEle mentById("tbl_t ype_h");
                    tbl_type_h.enabled=true;

                    no quotes on the true/false

                    Comment

                    Working...