Advertisement
Guest User

Untitled

a guest
Apr 29th, 2013
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2.  
  3. <html>
  4. <head>
  5. <title>jQuery Vacation Images</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  7. <link rel="stylesheet" href="vacation.css">
  8. <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  9. <script src="jquery.js"></script>
  10. <script type="text/javascript">
  11.  
  12. $(document).ready(function() {
  13. $("#vacationimages img").click(function() {
  14. var changeSrc = $(this).attr("src");
  15. var changeAlt = $(this).attr("alt");
  16. $("#currentimg").attr("src", changeSrc); //code to show large clicked image on the right
  17. $("#imagedesc").text(changeAlt); //code to show alt under the large image in text
  18. }); //end of vacation mouse click verification
  19.  
  20. $("#submitme").click(function () {
  21. $("#question span").text("");
  22. $("#mymessage").text("");
  23. var myname = $("#firstname").val();
  24. if (myname == '') {
  25. $("#question span").text("Must enter first name");
  26. return;
  27. }
  28. $("#vacationimages img").click(function() {
  29. var changeAlt = $(this).attr("alt");
  30. $(this).data('clicked', true);
  31. if (myname !== "" || (#vacationimages img).data('clicked'))
  32. {
  33. $("#mymessage").text(myname + " you want a " + changeAlt + " vacation"); //if image clicked and name is set this message will show under the "Submit Me" button
  34. }
  35. }) //end of Name Verification for empty field
  36.  
  37. }) //end of Submit Me button handler
  38.  
  39. }) // END OF READY
  40.  
  41. </script>
  42.  
  43. </head>
  44.  
  45. <body>
  46.  
  47.  
  48. <div id="question">
  49. <h2>jQuery Vacation Images</h2>
  50. <p>What is your first name?
  51. <input type="text" id="firstname" size="30">
  52. <span></span>
  53. </p>
  54. </div>
  55.  
  56. <div id="vacationimages">
  57. <p>Click on the Image that best represents the kind of vacation you want</p>
  58. <p><img src="mountain.jpg" alt="Mountain Vacation"><br /><br /></p>
  59. <p><img src="desert.jpg" alt="Desert Vacation"><br /><br /></p>
  60. <p><img src="ocean.jpg" alt="Ocean Vacation"><br /><br /></p>
  61. </div>
  62.  
  63. <div id="bigimage">
  64. <img id="currentimage" src="ocean.jpg" alt="ocean vacation" width="300" height="225" border="0">
  65. <p id="imagedesc"></p>
  66. </div>
  67.  
  68. <div id="showhidebuttondiv">
  69. <input id="showhidebutton" type="button" value="Hide Image">
  70. </div>
  71.  
  72.  
  73. <div id="submitdiv">
  74. <input id="submitme" type="button" value="Submit ME">
  75. <p id="mymessage"></p>
  76. </div>
  77.  
  78.  
  79.  
  80.  
  81. </body>
  82. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement