Form submission uses only the element name; jQuery and other 
JavaScript/DHTML references, as well as HTML certification, require a 
unique ID.

These 2 can be set independently and still work correctly.

As Klaus said, having the IDs as non-unique is adding problems for yourself.

If you can get the database to generate the form element's "*name*" tag 
but add some sort of unique prefix/suffix to the form's "*id*" tag, you 
should be OK; simply reference the unique ID (prefix/suffix + the 
original name) when using jQuery.

L

Klaus Hartl wrote:
> 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
> discuss@jquery.com
> http://jquery.com/discuss/
>
>   

-- 
Regards,
Liam

 
------------------------------------------------------------------------
Liam Byrne

*OnSight.ie
*/Winner of Limerick City Enterprise Board's "Best New Technology 
Business 2004" Award
/
web: http://www.onsight.ie email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
phone: 061 22 99 86
mobile:087 2730 270

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to