开发者

while() and onclick

开发者 https://www.devze.com 2022-12-21 19:50 出处:网络
I have this: while( $rowData = @mysql_fetch_assoc($selectRows2) ) { ?> <div id=\"stemmeto\"><a href=\"#\" id=\"thelink\" onclick=\"window.parent.OpenVote(<? echo $_GET[\'id\']; ?>,

I have this:

    while( $rowData = @mysql_fetch_assoc($selectRows2) )
    {
?>
<div id="stemmeto"><a href="#" id="thelink" onclick="window.parent.OpenVote(<? echo $_GET['id']; ?>, '<? echo $rowData['username']; ?>');">
<?php echo $rowData['username']; ?> </a></div>

<div id="stemme">
<a href="开发者_开发知识库#" id="thelink" onclick="window.parent.OpenVote(<? echo $_GET['id']; ?>, '<? echo $rowData['username']; ?>');">
<? echo $rowData['stemme']; ?></div></a><br />
<?
    }

Now this should activate OpenVote function with (id, username) in the parent.window.. But for some reason this only works for first column, that comes out, nothing is happening when i click the others.. I have tried to remove that column, to check to see if its specially just that column, but it wasnt, its always the "first" column that echo´s out in the while(), that i can click on.. what should i do?

Here's the OpenVote script on the parent window(index.php)

function OpenVote(id, stemme)  {
  var postThisShit = 'battles/infoaboutvote.php?id='+id+'&stemme='+stemme;
  $.post(postThisShit, function(data){
        $(".showinfo").html(data).find(".getinfo").fadeIn("slow")
  });
  }

And the #thedialog on index.php:

<div id="thedialog" title="Showing..">
    <p class="showinfo">
        You shouldn't see this, something went wrong..
    </p>
</div> 


The id attribute must be unique across your entire document. Your loop is creating multiple elements with the same id, which will cause behavior like you're describing when trying to interact with the elements. Try appending a unique value to the end of the id, such as id-1, id-2, id-3, etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消