Sure, how i could miss that! I would assign the categories Id number (like $catid) in the Id attribute of the link. Then using it as a GET parameter for the load function. It would give: <a href="#" id="<?=$catid;?>" class="generate2"><?=$catname;?></a>
Then modify the function i wrote (based on the classname) using: $("#myobj").load("products.php?idctg_ctg=" + $(this).attr("id") ) Here's the complete script (tested!) from your source: [SCRIPT] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:// www.w3.org/TR/html4/loose.dtd"> <html> <head> <script src="scripts/jquery.js"></script> <script> $(document).ready(function(){ $(".generate2").each ( function () { $( this ).bind ( "click", function() { $("#myobj").fadeOut("fast"); $("#myobj").slideToggle("slow"); $("#myobj").load("products.php?idctg_ctg=" + $(this).attr('id') ); // id will be the one of the clicked link }//function );//bind }//function );//each }); </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="#" class="generate2" id="<?php echo $row_categorys['idctg_ctg']; ?>"><?php echo $row_categorys['name_ctg']; ?></a><br> <?php } while ($row_categorys = mysql_fetch_assoc($categorys)); ?> </div> </body> </html> <?php mysql_free_result($categorys); ?> But you can have a look at ricardobeat link ;) On 21 oct, 20:57, Flavio333 <[EMAIL PROTECTED]> wrote: > 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-prob... > Sent from the jQuery General Discussion mailing list archive at Nabble.com.- > Masquer le texte des messages précédents - > > - Afficher le texte des messages précédents -