Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3675566
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:59:31+00:00 2026-05-19T02:59:31+00:00

The page I’m working with is here: http://harrisonfjord.com/survey/index.html When you click on an object

  • 0

The page I’m working with is here:

http://harrisonfjord.com/survey/index.html

When you click on an object in each step, the “alt” tag of the image map region on which you clicked is being saved as a variable answer(current question number).

The code is here (ignore the comments, I’ve just put them in so I know what the hell I’m doing!):

$(window).load(function(){

        //#shape functions
        $('#shape area').hover(
            function(e){
                $('#'+ this.alt).addClass('hover');
            },
            function(e){
                $('#'+ this.alt).removeClass('hover');
            } //.hover allows 2 function - first is mouse on, second is mouse off
        ); //End #shape .hover function

        $('#shape area').click( //.click only allows 1 function.
            function(e){
                $('img.selected-region').removeClass('selected-region');
                $('#'+ this.alt).addClass('selected-region');
                var answer1 = $(this).attr("alt");
                alert(answer1);

            }
        );//End #Shape .click function



        //#height functions

        $('#height area').hover(
            function(e){
                $('#'+ this.alt).addClass('hover');
            },
            function(e){
                $('#'+ this.alt).removeClass('hover');
            }
        ); //End #height .hover function

        $('#height area').click(
            function(e){
                $('img.selected-region').removeClass('selected-region');
                $('#'+ this.alt).addClass('selected-region');
                var answer2 = $(this).attr("alt");
                alert(answer2 + answer1);

            }
        );//End #height .click function



        //#world functions
        $('#world area').hover(
            function(e){
                $('#'+ this.alt).addClass('hover');
            },
            function(e){
                $('#'+ this.alt).removeClass('hover');
            } 
        ); //End #world .hover function

        $('#world area').click(
            function(e){
                $('img.selected-region').removeClass('selected-region');
                $('#'+ this.alt).addClass('selected-region');
                var answer3 = $(this).attr("alt");
                alert(answer3);

            }
        );//End #world .click function           

    }); //End (window) onLoad function 

As you can see, I’m creating an alert for each variable just so I can see that it’s working when I click. However, after I press “next”, the variable seems to erase itself. As you can see, in the second step, I’m alerting (answer1 + answer2), yet nothing comes up. Further, if you check the html code for “step 4”, you’ll see that instead of images I’m running a simple document.write script:

<h3>
    <script type="text/javascript">
        document.write(answer1);
    </script>
</h3>   

yet, again, nothing displays. Why are my variables not persisting through the whole jquery survey?

Excuse the massive code below, but it might help resolve the issue – the entire .js code that runs the jquery survey steps, as well as the hover/click functions of each map.

(function($){

$(window).load(function(){

        //#shape functions
        $('#shape area').hover(
            function(e){
                $('#'+ this.alt).addClass('hover');
            },
            function(e){
                $('#'+ this.alt).removeClass('hover');
            } //.hover allows 2 function - first is mouse on, second is mouse off
        ); //End #shape .hover function

        $('#shape area').click( //.click only allows 1 function.
            function(e){
                $('img.selected-region').removeClass('selected-region');
                $('#'+ this.alt).addClass('selected-region');
                var answer1 = $(this).attr("alt");
                alert(answer1);

            }
        );//End #Shape .click function



        //#height functions

        $('#height area').hover(
            function(e){
                $('#'+ this.alt).addClass('hover');
            },
            function(e){
                $('#'+ this.alt).removeClass('hover');
            }
        ); //End #height .hover function

        $('#height area').click(
            function(e){
                $('img.selected-region').removeClass('selected-region');
                $('#'+ this.alt).addClass('selected-region');
                var answer2 = $(this).attr("alt");
                alert(answer2 + answer1);

            }
        );//End #height .click function



        //#world functions
        $('#world area').hover(
            function(e){
                $('#'+ this.alt).addClass('hover');
            },
            function(e){
                $('#'+ this.alt).removeClass('hover');
            } 
        ); //End #world .hover function

        $('#world area').click(
            function(e){
                $('img.selected-region').removeClass('selected-region');
                $('#'+ this.alt).addClass('selected-region');
                var answer3 = $(this).attr("alt");
                alert(answer3);

            }
        );//End #world .click function              

                // jQuery.extend merges contents of two or 
                // more objects together into the first object
                //$.extend(useranswers,{ 
                    //answer1 : $("img.selected-region").attr('rel') 
                //});

                //$.cookie('survery', 
                    //JSON.stringify(useranswers),
                    //{ expires: 7, path: '/', domain: '<your_domain_name>' }
                //);


    }); //End (window) onLoad function  

$.fn.smartWizard = function(options) {
        var defaults = {
              selectedStep: 0,  // Selected Step, 0 = first step
              errorSteps:[],    // Array Steps with errors
              enableAll:false,  // Enable All Steps, true/false
              animation:true,   // Animation Effect on navigation, true/false         
              validatorFunc:function(){return true;} // Step validation function, Step index will be passed
        };
        var options = $.extend(defaults, options);  

        return this.each(function() {
                obj = $(this); 
                var wizcurrent = 0;
                  var steps = $("ul > li > a", obj);
                  // Apply Default Style to Steps
                  applyCSS($(steps, obj),"wiz-anc-default");
                  // Hide All Steps on load
                hideAllSteps();

                $(steps, obj).bind("click", function(e){
                    e.preventDefault();
                    var isDone = $(this, obj).attr("isDone");
                    if(isDone == 1){
                        var selIdx = steps.index(this);  
                        applyCSS($(wizcurrent, obj),"wiz-anc-done"); 
                        selectStep(selIdx);
                    }
                });
                // activates steps up to the selected step
                for(i=0;i<steps.length;i++){
                  if(i<=options.selectedStep || options.enableAll==true){
                    activateStep(i);
                  }
                }
                // highlight steps with errors
                $.each(options.errorSteps, function(i, n){
                  //applyCSS(steps.eq(n),"wiz-anc-error");
                  setErrorStep(n)
                });

                  selectStep(options.selectedStep);
                //Next Navigation
                $(".next", obj).bind("click", function(e){
                  e.preventDefault();  
                  var curStepIdx = $(steps, obj).index(wizcurrent);
                  if(options.validatorFunc(curStepIdx)){
                      var nextStepIdx = curStepIdx+1;
                      applyCSS($(wizcurrent, obj),"wiz-anc-done"); 
                      selectStep(nextStepIdx);
                  }
                });

                //Back Navigation
                $(".back", obj).bind("click", function(e){
                  e.preventDefault(); 
                  applyCSS($(wizcurrent, obj),"wiz-anc-done"); 
                  var prevIdx = $(steps, obj).index(wizcurrent)-1;
                  selectStep(prevIdx);
                });

                function selectStep(idx){
                    if(idx < steps.length && idx >= 0){
                      var selStepAnchor = $(steps, obj).eq(idx);
                      var selStepIdx =selStepAnchor.attr("href");
                      hideAllSteps();          
                      selStepAnchor.attr("isDone","1");

                      if(options.animation==true){
                        $(selStepIdx, obj).fadeIn("fast");
                      }else{
                        $(selStepIdx, obj).show();
                      }
                      applyCSS($(selStepAnchor, obj),"wiz-anc-current");
                      wizcurrent = selStepAnchor;
                    }
                }

                function activateStep(idx){
                    var selStepAnchor = steps.eq(idx);
                    selStepAnchor.attr("isDone","1");
                    applyCSS($(selStepAnchor, obj),"wiz-anc-done");
                }

                function setErrorStep(idx){
                    var selStepAnchor = steps.eq(idx);
                    selStepAnchor.attr("isError","1"); 
                    $(selStepAnchor, obj).addClass("wiz-anc-error"); 
                }

                function unsetErrorStep(idx){
                    var selStepAnchor = steps.eq(idx);
                    selStepAnchor.attr("isError",""); 
                    $(selStepAnchor, obj).removeClass("wiz-anc-error"); 
                } 

                function hideAllSteps(){
                    $(steps, obj).each(function(){
                        $($(this, obj).attr("href"), obj).hide();
                  });
                }

                function applyCSS(elm,css){
                    $(elm, obj).removeClass("wiz-anc-default");
                    $(elm, obj).removeClass("wiz-anc-current");
                    $(elm, obj).removeClass("wiz-anc-done");
                    $(elm, obj).addClass(css); 
                }
        });  
    };  
})(jQuery);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:59:32+00:00Added an answer on May 19, 2026 at 2:59 am

    Since you are defining the variables “var answer1” within a function, they’re only defined in the scope of this function. Try this:

    $(window).load(function(){
    
        var answer1, answer2, answer3;
    
        //#shape functions
        $('#shape area').hover(
        ...
    

    Then loose the “var” within your click event functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Page - http://blu-eye.com/index.html - contains suckerfish menu which is displaying correctly on the rest
Page I'm working with is: http://cloudninetech.com/newsite/site/homepage.html Notice the tab slider at the bottom. I
Page in question: http://phwsinc.com/our-work/one-rincon-hill.asp In IE6-8, when you click the left-most thumbnail in the
page I'm working with: http://jsbin.com/abewe4 I want the slogan div centered inside col3 div
page.getByXPath(//*[@href='http://www.example.com/index.do/abc/1_*'); Do I need to escape any characters? I am trying to get all
My page's URL is like this: http://www.mydomain.com/directory/thisismy_page.html Using JavaScript, I want to pull out
page here: http://webpages.marshall.edu/~glasser1/jquery.html I'm trying to replicate the old twitter page login style. If
Page link I am working on is http://www.whatcar.com/car-news/subaru-xv-review/260397 I am trying to automate 'clicking
Page in question: http://secantmedical.com/biomedical-textiles/biomedical-textiles.php The heading area with the words Biomedical Textiles is set
On page 88 of Stephen Toub's book http://www.microsoft.com/download/en/details.aspx?id=19222 There is the code private BlockingCollection<T>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.