Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <tr><img id="i will put value for db processing"src="urlofimage"</tr> &nbsp;
  2.  
  3. $.fn.hasBorder = function() {
  4. if ((this.outerWidth() - this.innerWidth() > 0) || (this.outerHeight() - this.innerHeight() > 0)){
  5. return true;
  6. }
  7. else{
  8. return false;
  9. }
  10. };
  11. $(document).ready(function() {
  12. var selectedImgsArr = [];
  13. $("img").click(function() {
  14.  
  15. if($(this).hasBorder()) {
  16. $(this).css("border", "");
  17. //you can remove the id from array if you need to
  18. }
  19. else {
  20. $(this).css("border", "1 px solid red");
  21. selectedImgsArr.push($(this).attr("id")); //something like this
  22. }
  23. });
  24. });
  25.  
  26. <html>
  27. ...
  28. <td><img class='galImages' src='urlofimage' /></td>
  29. ...
  30. </html>
  31.  
  32. <script>
  33. $document.ready(function() {
  34. $('img.galImages').click(function() {
  35. if($(this).hasClass('selected') {
  36. $(this).removeClass('selected');
  37. }
  38. else {
  39. $(this).addClass('selected');
  40. }
  41. });
  42. });
  43. </script>
  44.  
  45. <style>
  46. .selected {
  47. 1px solid #f00;
  48. }
  49. </style>
  50.  
  51. <tr><img class="clickable" id="i will put value for db processing" src="urlofimage" /></tr>
  52.  
  53. <script>
  54. $(document).ready(function() {
  55. var clickedarray = new Array();
  56. $('.clickable').click(function() {
  57. //add border
  58. $(this).css({border: '1px solid #000'});
  59. //store in array
  60. clickedarray.push($(this).attr('id'));
  61. });
  62. });
  63. </script>
  64.  
  65. $(document).ready(function() {
  66. var selectedImgsArr = new Array();
  67. $("img").click(function() {
  68.  
  69. if($(this).hasClass("selected-image"))
  70. $(this).removeClass("selected-image");
  71. else
  72. $(this).addClass("selected-image");
  73. });
  74. $("form").submit(function(){
  75. selectedImgsArr.push($(".selected-image").attr("src"));
  76. })
  77. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement