Jeremy Dill schrieb:
> I am working on an application which uses a jquery to show and hide 
> preloaded layers sort of like netvibes.com. Another aspect of my 
> application involves dynamic creation of forms.  When these forms are 
> created, they are given an ID based on an ID in the database. 
>  
> It all worked out great before I went with the layering idea.  The 
> problem now is that I am often loading the same form elements on 
> different layers, and therefore the standard selector method of 
> $("#InputElementID") will not work since there are duplicate ID's hidden 
> in the background (in forms with different ID's).
>  
> So, 
>  
> 1) Do you think it will be reasonable to use a different selector method 
> to access the Input elements based on a combination of form ID and 
> element ID, rather than strictly by element id? If so, what syntax 
> should I use?  I have tried the context selector $('#InputID', 
> myFormObj) without much success.  Is there a better method?
>  
>  Or,
>  
> 2) Am I crazy to be creating a page containing duplicate elements even 
> though they are contained in different forms?


Yes to number 2) ;-)

An id serves as a *unique* identifier and as such it is supposed to be 
unique in a document. Scripting on top of an invalid HTML document won't 
make your life any easier.

That said, I strongly recommend another solution (creating valid, e.g. 
unique ids, use classes) but maybe you can get away with that:

$('#formId #inputId')

or (slower)

$('#formId [EMAIL PROTECTED]"inputId"]')

Again, you should consider this as a *dirty hack* and search for a 
proper solution.


-- Klaus


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to