Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Oct 2009
Posts: 44
Reputation: web3 is an unknown quantity at this point 
Solved Threads: 0
web3 web3 is offline Offline
Light Poster

Spry tabs

 
0
  #1
19 Days Ago
How to make something like spry tabs in dreamweaver with jquery or something. I don't have dreamweaver and i don't want to download a trial.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 433
Reputation: Atli is on a distinguished road 
Solved Threads: 56
Atli's Avatar
Atli Atli is offline Offline
Posting Pro in Training
 
0
  #2
16 Days Ago
Hey.

Creating a simple "tabs" system using AJAX is easy enough. Especially if you use jQuery, or something equivalent.
You could just put the contents of all your tabs in separate HTML files, and use AJAX to load them into a <div> in your HTML.

For example, assuming the following structure:
  1. root/
  2. index.html
  3. tabs.js
  4. styles.css
  5. tabs/
  6. tab1.html
  7. tab2.html
  8. tab3.html

You could simply do:
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>AJAX Tabs Example</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. <link rel="Stylesheet" type="text/css" href="styles.css">
  7. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  8. <script type="text/javascript" src="tabs.js"></script>
  9. </head>
  10. <body>
  11. <div id="TabContainer">
  12. <ul id="TabMenu">
  13. <li onclick="SwitchTab('tab1');">Tab 1</li>
  14. <li onclick="SwitchTab('tab2');">Tab 2</li>
  15. <li onclick="SwitchTab('tab3');">Tab 3</li>
  16. </ul>
  17. <div id="TabContents">Loading...</div>
  18. </div>
  19. </body>
  20. </html>
  1. /**
  2.  * File: tabs.js
  3.  */
  4. $(document).ready(function()
  5. {
  6. // When the page loads, load the first tab.
  7. SwitchTab('tab1');
  8. });
  9. function SwitchTab(tabName)
  10. {
  11. // Put a Loading message in the TabContents div
  12. $('#TabContents').html('Loading...');
  13.  
  14. // Create the URL to the tab's HTML page.
  15. var url = 'tabs/' + tabName + ".html";
  16.  
  17. // Fire of an AJAX query to get the tab HTML
  18. $.get(url, null, function(data){
  19. // Change the contents of the TabContents div to the returned HTML
  20. $('#TabContents').html(data);
  21. }, 'html');
  22. }

And to make it pretty: (And I use that term very lightly)
  1. /**
  2.  * File: styles.css
  3.  */
  4. root {
  5. display: block;
  6. font-size: 1.5em;
  7. font-family: Verdana, Arial, Sans;
  8. }
  9. #TabContainer {
  10. width: 550px;
  11. border: solid 1px #000000;
  12. margin: 15px auto;
  13. }
  14. #TabMenu {
  15. display: block;
  16. height: 25px;
  17. margin: 0;
  18. padding: 0;
  19. background-color: #bfbfbf;
  20. border-bottom: solid 1px #000000;
  21. }
  22. #TabMenu li {
  23. display: block;
  24. float: left;
  25. min-width: 50px;
  26. height: 25px;
  27. padding: 0 3px;
  28. background-color: #dfdfdf;
  29. border-right: solid 1px #333333;
  30. line-height: 25px;
  31. text-decoration: underline;
  32. cursor: pointer;
  33. }
  34. #TabMenu li:hover {
  35. background-color: #efefef;
  36. }
  37. #TabContents {
  38. clear: both;
  39. padding: 5px;
  40. }
Hope that helps.
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC