Results 1 to 6 of 6

Thread: How do get the dynamically generated id for a corresponding field?

  1. #1
    Join Date
    Jun 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How do get the dynamically generated id for a corresponding field?

    I have a textbox corresponds to that there is an icon. when i click on the icon it will open a pop up and the values which i select in the popup will be populated in the text box. This is done, my problem is iam generating the textbox and icon in an inner html and the id's are dynamically generated, i want to pass the dynamically generated id of the textbox to the OnClick function of the corresponding Icon.. how can i do that??

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Using innerHTML property can cause many problems, especially with forms. I suggest using the W3C methods for adding and removing elements.
    Yes, I know there are many examples of my not doing that on these forums. I'm a hypocrite.

    More pertinently to your question, you can use the id property of the element to access its id in string form.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by sthirunav
    I have a textbox corresponds to that there is an icon. when i click on the icon it will open a pop up and the values which i select in the popup will be populated in the text box. This is done, my problem is iam generating the textbox and icon in an inner html and the id's are dynamically generated, i want to pass the dynamically generated id of the textbox to the OnClick function of the corresponding Icon.. how can i do that??
    I have got exactly the same problem as u did. Did u solve that if so how did u do that?? How were you able to get that dynamically generated ID

    Any help is appreciated

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Er, try reading previous replies before posting your own?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jul 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    Er, try reading previous replies before posting your own?

    I only posted after going through all the replies and after having had myself sure that none of them works. Wanted an answer from those who really had an answer for my question

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    had myself sure that none of them works.
    If elements in your Javascript environment don't have id properties, there's something very wrong with your browser.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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