www.webdeveloper.com
Results 1 to 5 of 5

Thread: function(help)...

  1. #1
    Join Date
    Dec 2010
    Posts
    6

    function(help)...

    I am working on image gallery and so far I have found several that come close to doing what I want but none that simply do it right... so the obviously solution is to write my own gallery script... Or so thats what I thought days ago when I started this project.

    After stumbling around, I have finally figured out what I need to make use of .innerHTML replacements

    I want to show a list of thumbnail images, next to the main content container. When mousing over the thumbnail the content of the main content container would be replaced. <a onMouseOver='swap(content)'>

    I know it needs to be done through an .innerHTML= replacement because I intend on filling the main content container with images <img>, flash video <object .flv>, and embed quicktime plugins <embed .mov>. I have successfully tested these replacements with very simple scripts like:

    function MainContentSwap(){
    document.getElementById('MainContentContainer').innerHTML = '<img src="..replacementImage" ></img>'; }

    function MainContentReturn(){
    document.getElementById('MainContentContainer').innerHTML = '<img src="orginalImage" ></img>';}


    But I would need a function for every thumbnail, which would be ridiculous.
    So I need an array of thumbnails and of replacement divs, I think..?

    <a id=thumbnail, #" onMouseOver='MainContentSwap'><img src="..." /></a>
    <div id="MainContent, #" class="hidden"><"img or .flv or .mov"> </div>

    I would appreciate and advice or links to useful How Tos...

  2. #2
    Join Date
    Dec 2010
    Posts
    6

    function (help)... V2

    After nearly 50 people have looked at my previous post without reply I figured my question was not clear, so maybe this will make more sense.

    In the head...

    <script type="text/javascript" >
    function MainContentSwap(idNumber){
    document.getElementById('MainContentContainer').innerHTML = [idNumber];
    }
    </script>


    Later in the body...

    <a id="thumbnail" onMouseOver="MainContentSwap(1)"><img src="images/image1.jpg"></a>
    <div id="1" class="hidden"><img src="/V2/image-slideshow-vertical/images/image1_big.jpg"/> </div>

    <a id="thumbnail" onMouseOver="MainContentSwap(2)"><img src="images/image2.jpg"></a>
    <div id="2" class="hidden"><img src="/V2/image-slideshow-vertical/images/image2_big.jpg"/> </div>

    <a id="thumbnail" onMouseOver="MainContentSwap(3)"><img src="images/image3.jpg"></a>
    <div id="3" class="hidden"><img src="/V2/image-slideshow-vertical/images/image2_big.jpg"/> </div>

    <a id="thumbnail" onMouseOver="MainContentSwap(4)"><img src="images/image4.jpg"></a>
    <div id="4" class="hidden"><img src="/V2/image-slideshow-vertical/images/image4_big.jpg"/> </div>

    There are more but the format does not change.
    Currently if I mouse over any of the thumbnails, the # from MainContentSwap(#) is input into the function and output into theMainContentContainer as only the #. Literally a number (1,2,3,etc) floating in the middle of the div 'MianContentContainer' all by itself.

    I need it to output the entire div that has that id="#".

    I have tried div[idNumber], with no luck.

    Any ideas..?

  3. #3
    Join Date
    Aug 2009
    Posts
    593
    Hopefully what you are looking for...

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    	<head>
    		<title>Image Gallery</title>
    		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    		<style type="text/css">
    
    			.thumbnail IMG {
    				border: solid 1px black;
    				width: 50px;
    				height: 50px;
    			}
    			.hidden {
    				display: none;
    			}
    			#MainContentContainer {
    				border: solid 1px black;
    				width: 200px;
    				height: 200px;
    			}
    
    		</style>
    
    		<script type="text/javascript">
    
    			function MainContentSwap(idNumber){
    				document.getElementById('MainContentContainer').innerHTML = document.getElementById('E' + idNumber).innerHTML;
    			}
    
    		</script>
    
    	</head>
    	<body>
    
    		<div id="MainContentContainer"></div>
    
    		<a class="thumbnail" onmouseover="MainContentSwap(1);"><img src="images/image1.jpg" alt="" /></a> 
    		<div id="E1" class="hidden"><img src="/V2/image-slideshow-vertical/images/image1_big.jpg" alt="" /></div>
    
    		<a class="thumbnail" onmouseover="MainContentSwap(2);"><img src="images/image2.jpg" alt="" /></a> 
    		<div id="E2" class="hidden"><img src="/V2/image-slideshow-vertical/images/image2_big.jpg" alt="" /></div>
    
    		<a class="thumbnail" onmouseover="MainContentSwap(3);"><img src="images/image3.jpg" alt="" /></a>
    		<div id="E3" class="hidden"><img src="/V2/image-slideshow-vertical/images/image2_big.jpg" alt="" /></div>
    
    		<a class="thumbnail" onmouseover="MainContentSwap(4);"><img src="images/image4.jpg" alt="" /></a> 
    		<div id="E4" class="hidden"><img src="/V2/image-slideshow-vertical/images/image4_big.jpg" alt="" /></div>
    
    	</body>
    </html>
    I added some extra styles you may not need, just so I could see where the images were.
    Ids should not start with a number, and should also be unique (thumbnail).

  4. #4
    Join Date
    Dec 2010
    Posts
    6
    Thanks for the update, that really helps.

    Now I can move on to step number 2, fading between one image and the next.

    : )

  5. #5
    Join Date
    Dec 2010
    Posts
    6
    Quote Originally Posted by thraddash View Post
    Hopefully what you are looking for...

    Thanks again for getting me on the right path. : )
    Feel free to check out the finished product: http://mgarito.com/V2/Pages/firefly.php


    Note this is the only page that has been rebuilt, so bulk of the menu links will not work.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.09579 seconds
  • Memory Usage 2,892KB
  • Queries Executed 15 (?)
More Information
Template Usage (34):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_html
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (5)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates