By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,349 Members | 1,353 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,349 IT Pros & Developers. It's quick & easy.

How to do the multiple items with the same id?

P: 17
Hi all,
I'm having the problem while using the edit-in-place scripts from internet. It's ok when i just used for one text id, but after i added a while loop because of multiple items and it become only the 1st text id content works. So below here i post a piece of my code, hope any here can help on this. How to do the multiple items with the same id? Please help. Thank you very much.

[PHP]while($disp=mysql_fetch_array($disp_de))
{
echo '<tr><td>';
$dis= $disp['pp_desc'];
echo "<p id=\"desc\">".$dis."</p>";
echo '</td></tr>';
}[/PHP]
Mar 2 '08 #1
Share this Question
Share on Google+
5 Replies


Markus
Expert 5K+
P: 6,050
You can't dop multiple items with the same id; they're intended t be unique.

And also, thanks!
I've been looking for something like this :P
Mar 2 '08 #2

P: 17
hi, ic but do you know how to solve this? Because I need it to be display and editable in place. But since that can't be same id then does it have any other choices to do this? for example, like flickr. It can be edited after one click although with multiple editable id or whatever...do you know this? Thanks.
Mar 3 '08 #3

Markus
Expert 5K+
P: 6,050
Through the onclick of an element you could pass the id of said element to the javascript function.
Expand|Select|Wrap|Line Numbers
  1. function editable(elementID, otherVars)
  2. {
  3. // code 
  4. }
  5.  
Expand|Select|Wrap|Line Numbers
  1. <p id="something" onclick="editable(this, something_else)">
  2. sdsfsdf</p>
  3.  
Mar 3 '08 #4

P: 17
thanks, I'll try but i don't really god in javascripts.
Mar 3 '08 #5

ronverdonk
Expert 2.5K+
P: 4,258
thanks, I'll try but i don't really god in javascripts.
In order to make your ID's unique is to use a sequence counter and concat that to the name 'desc', so in your code e.g.[php]$i=0;
while($disp=mysql_fetch_array($disp_de))
{
echo '<tr><td>';
$dis= $disp['pp_desc'];
echo "<p id='desc".$i."'>$dis</p>";
echo '</td></tr>';
$i++;
}[/php]
Most likeable success on JavaScript help with problems is in the JavaScript forum.

Ronald
Mar 3 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.