If you choose to do it this way, I'd advise using a timestamp rather than (or in conjunction with) the random string generator, just to ensure it's definitely unique. Entropy's a bitch...
On Dec 22, 9:16 am, "Calvin Lai" <cal...@gmail.com> wrote: > Maybe you could write a random generator script that generates and stores a > set of random letters and numbers, store it in a global array, and keep > checking against that array every time you load a record from the database. > Just make sure you insert the original record id into the inplaceeditor > script as a parameter so it reaches the server-side file that you're going > to use. > > -- > Calvin Lai > Business Developmenthttp://dealspl.us > > On Mon, Dec 22, 2008 at 1:07 AM, Matt Andrews <mattpointbl...@gmail.com>wrote: > > > > > You could just make your code into a function and pass the same php > > variable as the parameter: > > > function newInPlaceEditor(itemID) > > { > > new Ajax.InPlaceEditor('title_'+itemID, '/demoajaxreturn.html', {rows: > > 15,cols:40}); > > } > > > then your code: > > > <div id='title_<?php echo '$id'?>'><a href="javascript://" > > onclick='newInPlaceEditor(<?php echo '$id'; ?>'>edit me</a></div> > > > (not tested) > > > Matt > > > On Dec 20, 10:41 pm, Audg <abe...@ccc.edu> wrote: > > > Hi, > > > > I was wondering if anyone could lend a hand with the fabulous > > > Ajax.InPlaceEditor script! > > > > My question is this: Is there a way to generate an ID on the fly that > > > would make the id unique? > > > > Because I have a one-to-many situation with my database, there are > > > times when I'm displaying multiple records, which would result in > > > duplicate item ID's and confuse the script. > > > > For example, One Author could have many book titles...but I don't know > > > how many books the author has written until I query the database....so > > > I would need to create the id's on the fly. > > > > I can make the div dynamic with php <div id='title_<?php echo > > '$id'?>'>edit me</div> > > > > but is there a way to pass this same id to the new Ajax.InPlaceEditor > > > to make it match? > > > > <script type="text/javascript"> > > > new Ajax.InPlaceEditor('editme_THIS_WOULD_BE_A_UNIQUE_RECORD_ID', '/ > > > demoajaxreturn.html', {rows:15,cols:40}); > > > </script> > > > > Thanks for any help you can provide! > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---