LAGirl Posted May 10, 2013 Share Posted May 10, 2013 I have a table displaying database data and there's a "Dead" button next to each row for users to click when the information in that row is dead. When the button is clicked the info in the row is crossed out. Now this works, but the change isnt permanent. When I refresh the page, the row is no longer crossed out. I think I have to set cookies.. ? but I am unsure on how to do this. Are there any tutorials or something I can watch on this. Just looking at http://php.net/manual/en/function.setcookie.php is not helping. I'm reading it and my brain is like.. what?!?! How do I apply that to what I want to do? Here's my code php <?php while($row = $data->fetch_assoc()) { ?> <tr> <td><?php echo $row['title']; ?> </td> <td><?php echo $row['requester']; ?></td> <td><?php echo $row['reward']; ?></td> <td><?php echo $row['qual']; ?></td> <td><?php echo $row['time']; ?></td> <td><?php echo $row['category']; ?></td> <td><a href="<?php $row['link']; ?>"><button class="btn btn-mini btn-primary" type="button">Do This Hit</button></a></td> <td><button class="btn btn-danger btn-mini dead" type="button">Dead</button></td> </tr> <?php } ?> and here's my javascript $('table').on('click','.dead',function(){ $(this).parent().siblings().css({textDecoration: 'line-through'}); }); I'm just totally stuck right now, so any help is appreciated. Also, if cookies arent the way to go, please feel free to suggest other ways. Thanks. Quote Link to comment Share on other sites More sharing options...
LAGirl Posted May 10, 2013 Author Share Posted May 10, 2013 edit: actually im thinking cookies arent the way to go. That would just change the text for that specific user i think and i dont want that. I want the change to be permanent once someone clicks that button. so now im thinking i should use.... ajax? $.ajax({ type: "POST", url: url, data: data, success: success, dataType: dataType }); Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted May 10, 2013 Share Posted May 10, 2013 How permanent do you want it? If it's permanent permanent I would store it in a database somewhere. If it's just somewhat permanent, since you're already using jQuery, use jQuery.ajax to post to server and store a session variable. Then use that session variable to determine whether it's dead or not when initially loading the page. I have a table displaying database data and there's a "Dead" button next to each row for users to click when the information in that row is dead. When the button is clicked the info in the row is crossed out. Now this works, but the change isnt permanent. When I refresh the page, the row is no longer crossed out. I think I have to set cookies.. ? but I am unsure on how to do this. Are there any tutorials or something I can watch on this. Just looking at http://php.net/manual/en/function.setcookie.php is not helping. I'm reading it and my brain is like.. what?!?! How do I apply that to what I want to do? Here's my code php <?php while($row = $data->fetch_assoc()) { ?> <tr> <td><?php echo $row['title']; ?> </td> <td><?php echo $row['requester']; ?></td> <td><?php echo $row['reward']; ?></td> <td><?php echo $row['qual']; ?></td> <td><?php echo $row['time']; ?></td> <td><?php echo $row['category']; ?></td> <td><a href="<?php $row['link']; ?>"><button class="btn btn-mini btn-primary" type="button">Do This Hit</button></a></td> <td><button class="btn btn-danger btn-mini dead" type="button">Dead</button></td> </tr> <?php } ?> and here's my javascript $('table').on('click','.dead',function(){ $(this).parent().siblings().css({textDecoration: 'line-through'}); }); I'm just totally stuck right now, so any help is appreciated. Also, if cookies arent the way to go, please feel free to suggest other ways. Thanks. Quote Link to comment 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.