Re: Randomely generated numbers for select elements

akira <nhytro-python-S0/[email protected]>
Newsgroups gmane.comp.python.formencode
Message-ID <[email protected]>
Thanks for the info Ian, I´ll go with large random numbers, I wont have 
to change my backend code then.

Ian Bicking wrote:
> akira wrote:
>> Hi all,
>>
>> I have javascript code that allows me to duplicate HTML select 
>> elemets, although the users can delete the elements, each newly 
>> generated element gets a new name number in ascemding order, for 
>> example:
>> <input id="test-0" type="checkbox" name="test-0" 
>> value="${c.publicize}" checked="${c.publicize}">
>> <input id="test-1" type="checkbox" name="test-1" 
>> value="${c.publicize}" checked="${c.publicize}">               <input 
>> id="test-2" type="checkbox" name="test-2" value="${c.publicize}" 
>> checked="${c.publicize}"> 
>> this works till the user posts the form, and I create new elemenets 
>> based on waht I retrieved  from formencode, since I just generate new 
>> names and ids in ascending order, things get out of sync  on the 
>> front-end.
>>
>> I wpuld like to know if formencode can also deal with randomly 
>> generated values like:
>>
>>
>> <input id="test-131"
>> <input id="test-424"
>> <input id="test-244"
>>
>> would I still be able to access the values with my existing code, 
>> would they still be grouped?
>
> Sure, it just sorts them by number, and then groups.  But then it'll 
> probably recreate.
>
> Maybe you should use test.x131, test.x424, etc -- using a dictionary 
> instead of a list.  You'll need to use something like ForEach, but 
> that knows about dictionaries; neither Schema nor ForEach will really 
> work right, but adapting ForEach shouldn't be too hard.
>
>   Ian
>
>


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.