Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript">
- //<![CDATA[
- $(document).ready(function(){
- /** Show and hide the dropdown body when the link is clicked **/
- $('div#dropdownlink').click(function(){
- $('div#dropdownbody').toggle();
- });
- /** Hide the dropdown body when an option is clicked and set a hidden form field to the selected value **/
- $('div#dropdownbody li').click(function(){
- $('#shape').val($(this).attr('title'));
- $('div#dropdownbody').toggle();
- });
- });
- //]]>
- </script>
- <style type="text/css">
- .clear{clear: both;}
- #dropdownlink {border: 1px solid #000;margin: 10px;padding: 5px;width: 150px;cursor: pointer;}
- #dropdownbody {width: 250px;border: 1px solid #000;padding: 5px;margin: -11px 0 0 10px;display: none;}
- #dropdownbody ul {list-style-type: none;margin: 0;padding: 0;}
- #dropdownbody ul li {float: left;width: 40px;padding: 5px;margin: 0;text-align: center;}
- </style>
- <title>Dropdown Test</title>
- </head>
- <body>
- <input type="hidden" name="shape" id="shape" value="" />
- <div id="dropdownlink">Select Shape</div>
- <div id="dropdownbody">
- <ul>
- <li title="testing 1">sdf</li>
- <li title="testing 2">sdf</li>
- <li title="testing 3">sdf</li>
- <li title="testing 4">sdd</li>
- <li title="testing 5">sfd</li>
- <li title="testing 6">sdf</li>
- <li title="testing 7">sdf</li>
- <li title="testing 8">sdf</li>
- <li title="testing 9">sdd</li>
- <li title="testing 10">sfd</li>
- <li title="testing 11">sdf</li>
- <li title="testing 12">sdf</li>
- <li title="testing 13">sdf</li>
- <li title="testing 14">sdd</li>
- <li title="testing 15">sfd</li>
- </ul>
- <br class="clear" />
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement