I tried what you said but it does not work... now both links go to the same
page when clicked...






RotinPain wrote:
> 
> 
> the problem is quite simple i think, all your links have the same id
> (generate2)
> And the jquery function is attached to a link with this id (generate2)
> So only 1 link will be responding to the function.
> 
> You need to use each() to attach an event to each links. Like
> 
> $("#generate2").each (
>   function () {
>     $( this ).bind (
>       "click",
>       function(){
>         //dosomething your stuff here
>       }//function
>     );//bind
>   }//function
> );//each
> 
> This should normally work. But note that only one unique ID per page
> is acceptable (see W3C recommandations). Better to use class name
> filtering instead (there could be more than 1 time the same class on
> the page but only 1 unique id).
> It will only change the first line:
> $(".generate2").each ( ...
> 
> And the HTML will looks like
>  # ... 
> 
> On Oct 21, 3:56 pm, Flavio333 <[EMAIL PROTECTED]> wrote:
>> Hello, I an quite new to jquery and hope someone can help with my
>> problem.  I
>> am trying to load dynamic content in to a div(myobj)... the code i have
>> so
>> far is more or less as follows.  it creates a box with 2 links, that it
>> gets
>> from 'name_ctg'.  the links, are category names and when clicked should
>> load
>> products.php, with the right product, as was determined by the link that
>> was
>> clicked.  I hope that make sense...  now the problem is that only the
>> first
>> link works, the second link does nothing.  I hope someone can help.
>>
>> <script src="jquery.js"></script>
>>
>>  <script>
>>   $(document).ready(function(){
>>  $("#generate2").click(function(){  
>>          $("#myobj").fadeOut("fast");
>>  $("#myobj").slideToggle("slow");
>>  $("#myobj").load("products.php?idctg_ctg=<?php echo
>> $row_categorys['idctg_ctg']; ?>");
>>   });
>>
>>  });
>>   </script>
>>
>>  <style type="text/css">
>> <!--
>> #myobj {
>>  background-color: #9999CC;
>>  height: 300px;
>>  width: 500px;}
>>
>> -->
>>  </style>
>> </head>
>>
>> <body>
>>
>> <div id="myobj" align="center">
>>   <?php do { ?>  
>>   < a  href="#" id="generate2" ><?php echo $row_categorys['name_ctg']; ?>
>> <br>
>>   <?php } while ($row_categorys = mysql_fetch_assoc($categorys)); ?>
>>    </div>
>> </body>
>> </html>
>> <?php
>> mysql_free_result($categorys);
>> ?>
>>
>> --
>> View this message in
>> context:http://www.nabble.com/can-someone-please-help-with-dynamic-links-prob...
>> Sent from the jQuery General Discussion mailing list archive at
>> Nabble.com.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/can-someone-please-help-with-dynamic-links-problem--tp20090838s27240p20097081.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to