How to do the multiple items with the same id?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • littlegreen
    New Member
    • Mar 2008
    • 17

    How to do the multiple items with the same id?

    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=mys ql_fetch_array( $disp_de))
    {
    echo '<tr><td>';
    $dis= $disp['pp_desc'];
    echo "<p id=\"desc\">".$ dis."</p>";
    echo '</td></tr>';
    }[/PHP]
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    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

    Comment

    • littlegreen
      New Member
      • Mar 2008
      • 17

      #3
      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.

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Through the onclick of an element you could pass the id of said element to the javascript function.
        [code=javascript]
        function editable(elemen tID, otherVars)
        {
        // code
        }
        [/code]
        [code=html]
        <p id="something" onclick="editab le(this, something_else) ">
        sdsfsdf</p>
        [/code]

        Comment

        • littlegreen
          New Member
          • Mar 2008
          • 17

          #5
          thanks, I'll try but i don't really god in javascripts.

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            Originally posted by littlegreen
            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=mys ql_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

            Comment

            Working...