How to access multi select with the same ID

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jiujing
    New Member
    • Apr 2010
    • 4

    #1

    How to access multi select with the same ID

    I need to use this tabbed form. Some of the select fields in one tab is the same as those in the other. How do I change the selection in tab 1 and get the same field in tab 2 changed?

    Please see what do I mean at

    http://satret1.met.fsu .edu/TestJava/tabbedFormDemo. html

    If I change the title in "Contact Detail", how do I get the title changed in "Delivery Details"?

    Thanks,
  • chathura86
    New Member
    • May 2007
    • 227

    #2
    it is not good to duplicate the id, it should be unique.

    you can use form.name to select the elements and change the values

    Regards

    Comment

    • Jiujing
      New Member
      • Apr 2010
      • 4

      #3
      Thanks for your reply.

      I understand it's not a good idea to duplicate id. However, they are really
      the same field showing in different tabs. Do you have any idea what's
      the best way to deal with this? Right now I could only control the field
      in the 1st tab.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        it is not just a bad idea, it is plain wrong ... the purpose of an id is to be unique. In fact in your code it is NOT the same field ... it is ANOTHER node with the same id which destroys the possibility to use DOM methods reliably. You would either need to dynamically move the node from tab to tab so that it would always be the SAME node or give it another unique id and set its value onchange of the first select-node ...

        kind regards

        Comment

        • Jiujing
          New Member
          • Apr 2010
          • 4

          #5
          Thank you very much. Do you have an example on how to dynamically move the node from tab to tab handy?

          Jiujing

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            you would need to use DOM methods like removeChild() and appendChild() or insertBefore() for this ... here you will find some examples for this

            Comment

            • Jiujing
              New Member
              • Apr 2010
              • 4

              #7
              Thank you!

              Comment

              Working...