RE: Javascript GetElementByID

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #46
    and next time, when I’m not around to have a look at? you need to learn to get better and that requires effort.

    Comment

    • chandhseke
      New Member
      • Jun 2009
      • 92

      #47
      Yes thats right!! I was running out of time so was in a hurry to get an answer.

      So we need to replace "this" with a select item reference.

      document.getEle mentById("hidte xt").value = document.getEle mentById("selec t").options[select.selected Index].text;

      or

      document.getEle mentById("hidte xt").value = document.getEle mentById("selec t").options[document.getEle mentById("selec t").selectedInd ex].text;
      Please advise.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #48
        second one looks correct. first one: select is undefined.

        PS. as you can see, there is less code to write using this (one argument to use it)

        Comment

        • chandhseke
          New Member
          • Jun 2009
          • 92

          #49
          Thats awesome you made me think and do it by my own. I really very thank ful to you. i always look forward to work with you in future.

          Thanks a lot and the code is working as intended!!

          Chandhseke

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #50
            I still know how hard it was to understand Closures.

            Comment

            Working...