madmenyo Posted September 19, 2010 Share Posted September 19, 2010 Hi folks, I try to keep my explanation as short as possible. I have a page that loads a php script on opening with all the cards in my database. When a player clicks a div of a specific card div a popup comes up asking if he wants to add this card to his collection. When choosing yes the specific card goes into his private collection. Problem is, the card div has already got an ID for layout purpose. Can i give this div somekind of extra info while generating them from my PHP script. And then sent that info back to the PHP script that should add the card to the players DB. I am using Jquery to sent and receive data from my php script something like this. <script> $(document).ready(function(){ $('#halfrow').click(function(){ //<-- the div that gets clicked $('#popuplarge').css({'visibilty':'visible'}) //<-- the popup $.post( "addcard.php", { cardID: $("#cardDiv").val()}, //<--- here i sent the info to the php script so the correct card can be added. function(data) { $("#popuplarge").html(data); }); }); }); </script> Is there a way to add a hidden <input /> with the card ID div and then sent that trough with Jquery? Still the same problem here as all the divs have the same ID and the jquery script would not know witch hidden <input /> to sent. I could also make the whole div a button but thats probably not desirable for layout purpose. I can always add a button to the div wich has to be clicked. But i would really like the user can click anywhere on the div. And i rather not want to redesign the div . Quote Link to comment https://forums.phpfreaks.com/topic/213795-passing-through-information-to-php-by-clicking-div/ Share on other sites More sharing options...
madmenyo Posted September 19, 2010 Author Share Posted September 19, 2010 As always a couple of minutes after my post i fix things . Please ignore all my future posts.... I was able to give the card DIV a title and sent that with Jquery through this line: $.post( "recruitcode.php", { cardID: $(this).attr("title")} Now i can generate all these divs and give them the correct title. Then when i click 'm i can sent the correct information to the script that adds them to the players private DB. Anyways, if you know of other ways i'd really like to know as title allows you to sent only 1 variable. Fortunately i only need just 1. Quote Link to comment https://forums.phpfreaks.com/topic/213795-passing-through-information-to-php-by-clicking-div/#findComment-1112732 Share on other sites More sharing options...
madmenyo Posted September 19, 2010 Author Share Posted September 19, 2010 Lol title gives me a tool tip.... mehhh... I mark this one unsolved again as i'm really looking for a better way to do this. Quote Link to comment https://forums.phpfreaks.com/topic/213795-passing-through-information-to-php-by-clicking-div/#findComment-1112741 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.