PDA

View Full Version : How do get the dynamically generated id for a corresponding field?



sthirunav
06-15-2006, 06:41 PM
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??

Twey
06-15-2006, 07:13 PM
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.

sxm7723
07-17-2006, 04:53 PM
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

Twey
07-17-2006, 04:58 PM
Er, try reading previous replies before posting your own?

sxm7723
07-17-2006, 06:06 PM
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

Twey
07-17-2006, 06:55 PM
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.