www.webdeveloper.com
Results 1 to 2 of 2

Thread: How to change a variable by clicking a link?

  1. #1
    Join Date
    Dec 2012
    Posts
    1

    How to change a variable by clicking a link?

    I have a website with java script that references a gallery ID as a text string. I want to have the user click a link and change that gallery ID so they see a different gallery. Here's a snippet of the code:

    Code:
    /********************************************************
     * Fullscreen Slideshow JS
     *
     * By: FastLine Media - http://www.fastlinemedia.com
     *******************************************************/
      
    YE.onDOMReady(function()
    {
    	if(YD.hasClass(document.body, "homepage") && YD.hasClass(document.body, "notLoggedIn")) {
    	
    		var hideOn = [
    			'mycustompage',
    			'galleries',
    			'map',
    			'featured',
    			'recent',
    			'featured-events',
    			'find',
    			'mysearch'
    		];
    		
    		for(var i = 0; i < hideOn.length; i++) {
    			if(YD.hasClass(document.body, hideOn[i])) {
    				return;
    			}
    		}
    	
    		var ss = new FL.widget.Slideshow({
    			id:document.body,
    			sourceType:'smugmug',
    			source:{
    				APIKey:'7w6kuU5Ee6KSgRRExf2KLgppdkez9JD2',
    				gallery:'22116386_jrvL6b'
    			},
    			speed:5000,
    			stretchy:true,
    			useGrid:false,
    The line that needs to be changed is 5th from the bottom: gallery:'22116386_jrvL6b'
    Again, in my navigation bar at the top i'd like to click home and have the value be '22116386_jrvL6b' and then click portfolio and have the value change to '22234234_ghklrhwjfh'

    Let me know if you need more code to answer the question.
    Any help would be greatly appriciated,
    -OD

  2. #2
    Join Date
    Nov 2006
    Location
    Oakland
    Posts
    500
    It appears all variables in your Javascript code are initialize when the DomReady event is fired.
    You need to break down that code for more flexibility. For instance you can create a function that takes the slideshow id as its argument.

    function getSlideShow(galleryid){
    return new FL.widget.Slideshow({
    id:document.body,
    sourceType:'smugmug',
    source:{
    APIKey:'7w6kuU5Ee6KSgRRExf2KLgppdkez9JD2',
    gallery:galleryid
    },
    speed:5000,
    stretchy:true,
    useGrid:false,
    ..... //adtional parameters
    );

    }

    Now you can set your variable ss with a call:

    var ss=getSlideShow('22116386_jrvL6b');

    Of course, we need to see more of your JavaScript code if you need further assistance.

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



Recent Articles