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:

then your code:

<div id='title_<?php echo '$id'?>'><a href="javascript://"
onclick='newInPlaceEditor(<?php echo '$id'; ?>'>edit me</a></div>

(not tested)


On Dec 20, 10:41 pm, Audg <> 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
> 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 &" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to