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 9189177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:11:08+00:00 2026-06-17T20:11:08+00:00

This script was written by someone else, who I am unable to consult. It

  • 0

This script was written by someone else, who I am unable to consult. It was written for an older version of jQuery, possibly jQuery 1.3, and worked perfectly on that version. On my new website, which uses a more recent version of jQuery (1.7 ?), the script is completely broken.

I was able to get it mostly working by replacing all occurrences of “$” with “jQuery”. I don’t know why that was necessary since all tutorials and examples I read online show the dollar sign being used.

However there is still a problem with the code. When an item is selected in the carousel, it doesn’t seem to change the radio button in the HTML to show that it is checked. I tried using .prop instead of .attr, per the documentation online, but it doesn’t work.

The Avatar Builder, which is what the script is part of, is present on the Edit Account page. I’ve created a test user on the new site so anyone who is willing to help, can test it.
You can login here: https://comm7.he2236.vps.webenabled.net/user/login
Username: testuser
Password: jQuery

Edit Account link: https://comm7.he2236.vps.webenabled.net/user/59/edit

The code I have currently mostly working, foster_avatar_widget.js
JS includes in the header can be viewed on: comm7.he2236.vps.webenabled.net

function select_avatar(image, button) {
image.input.prop('checked', true);
alert(image.input.is(':checked'));
jQuery('#layer_'+image.id).css({ backgroundImage: "url("+image.url+")" });

var src = button.attr("src");

button.parent().parent().find("li img").each(
    function(index) {
        if(jQuery(this).attr("src") == src)
        jQuery(this).addClass("avatar_select");
        else
        jQuery(this).removeClass("avatar_select");
    }
);
}

function unselect_avatar(image, button) {

image.input.prop('checked', false);

//select empty
jQuery('#default_input_'+image.id).prop('checked', true);

jQuery('#layer_'+image.id).css({ backgroundImage: "none" });

var src = button.attr("src");

button.parent().parent().find("li img").each(
    function(index) {
        if(jQuery(this).attr("src") == src)
        jQuery(this).removeClass("avatar_select");
    }
);
}

function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt) {
 var data = carousel.data;

 if(!data) {
     var cid = carousel.list.attr('id').substring(9);
    var data = new Array();
    jQuery('#'+cid+' img').each(
        function(index) {
            var input = jQuery(this).siblings('input');
            var url = jQuery(this).attr('src');

            if(input.is(':checked')) {
                    jQuery('#layer_'+cid).css({ backgroundImage: "url("+url+")" });                   
            }

            data.push({id: cid, input: input, image: jQuery(this), url: url});
        });

    carousel.data = data;

    jQuery('#user-edit').append('<div class="form-item" style="display:none"><label class="option"><input class="form-radio user_avatar_select" id="default_input_'+cid+'" type="radio" value="none" name="select_avatar_'+cid.substring(cid.lastIndexOf("_") + 1)+'"/></label></div>');
}

var idx = carousel.index(i, data.length);
var image = data[idx - 1];

var img = image.image.clone();

if(image.input.is(':checked'))
    img.addClass("avatar_select");

carousel.add(i, img);

img.hover(
    function(){jQuery(this).addClass("avatar_hover");},
    function(){jQuery(this).removeClass("avatar_hover");}
  );

img.click(
    function () {
        if(image.input.is(':checked'))
            unselect_avatar(image, jQuery(this));
        else
            select_avatar(image, jQuery(this));
    }
);
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
carousel.remove(i);
};

function mycarsousel_init(list) {
if(!list.attr('id'))
    return;

jQuery(".picture").append('<div class="avatar_layer" id="layer_'+list.attr('id')+'"></div>');

list.append('<ul id="carousel_'+list.attr('id')+'" class="jcarousel-skin-tango"></ul>');

jQuery('#carousel_'+list.attr('id')).jcarousel({
    scroll: 6,
    wrap: 'circular',
    //itemLoadCallback: itemLoadCallbackFunction,
    itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
    itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
});
}

jQuery(document).ready(function () {   
  jQuery('div.user_avatar_select').parent().hide();

  for(var i=0;i<10;i++) {
    mycarsousel_init(jQuery('#user_avatars_select_'+i));
  }

  jQuery(".picture #current").css({display: "none"});

  jQuery(".picture").css({"position": "relative", "width": "200px", "height": "200px", "background-image": "url(/sites/default/files/default_avatar.gif)"});
});

The code which worked on older jQuery
JS includes in the header can be viewed on: fclub.he2236.vps.webenabled.net

var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

function select_avatar(image, button) {
image.input.attr("checked", "checked");

if (jQuery.browser.msie && (ie55 || ie6)) {
    $('#layer_'+image.id).css('background-image', 'none');
    $('#layer_'+image.id).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + image.url + '\', sizingMethod=\'scale\');';
}
else {
    $('#layer_'+image.id).css({ backgroundImage: "url("+image.url+")" });
}

var src = button.attr("src");

button.parent().parent().find("li img").each(
    function(index) {
        if($(this).attr("src") == src)
        $(this).addClass("avatar_select");
        else
        $(this).removeClass("avatar_select");
    }
);
}

function unselect_avatar(image, button) {

image.input.attr("checked", "");

//select empty
$('#default_input_'+image.id).attr("checked", "checked");

$('#layer_'+image.id).css({ backgroundImage: "none" });

if (jQuery.browser.msie && (ie55 || ie6)) {
    $('#layer_'+image.id).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader none;';
}
else {
    $('#layer_'+image.id).css({ backgroundImage: "none" });
}

var src = button.attr("src");

button.parent().parent().find("li img").each(
    function(index) {
        if($(this).attr("src") == src)
        $(this).removeClass("avatar_select");
    }
);
}

function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt) {
 var data = carousel.data;

 if(!data) {
     var cid = carousel.list.attr('id').substring(9);
    var data = new Array();
    $('#'+cid+' img').each(
        function(index) {
            var input = $(this).siblings('input');
            var url = $(this).attr('src');

            if(input.attr("checked")) {
                if (jQuery.browser.msie && (ie55 || ie6)) {
                    $('#layer_'+cid).css('background-image', 'none');
                    $('#layer_'+cid).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + url + '\', sizingMethod=\'scale\');';
                }
                else {
                    $('#layer_'+cid).css({ backgroundImage: "url("+url+")" });
                }

            }

            data.push({id: cid, input: input, image: $(this), url: url});
        });

    carousel.data = data;

    $('#user-edit').append('<div class="form-item" style="display:none"><label class="option"><input class="form-radio user_avatar_select" id="default_input_'+cid+'" type="radio" value="none" name="select_avatar_'+cid.substring(cid.lastIndexOf("_") + 1)+'"/></label></div>');
}

var idx = carousel.index(i, data.length);
var image = data[idx - 1];

var img = image.image.clone();

if(image.input.attr("checked"))
img.addClass("avatar_select");

carousel.add(i, img);

img.hover(
    function(){$(this).addClass("avatar_hover");},
    function(){$(this).removeClass("avatar_hover");}
  );

img.click(
    function () {
        if(image.input.attr("checked"))
        unselect_avatar(image, $(this));
        else
        select_avatar(image, $(this));
    }
);
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};

function mycarsousel_init(list) {
if(!list.attr('id'))
return;

$(".picture").append('<div class="avatar_layer" id="layer_'+list.attr('id')+'"></div>');

list.append('<ul id="carousel_'+list.attr('id')+'" class="jcarousel-skin-tango"></ul>');

$('#carousel_'+list.attr('id')).jcarousel({
    scroll: 6,
    wrap: 'circular',
    itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
    itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
});
}

if (Drupal.jsEnabled) {
$(document).ready(function () {

  $('div.user_avatar_select').parent().hide();

  for(var i=0;i<10;i++)
  mycarsousel_init($('#user_avatars_select_'+i));

  $(".picture #current").css({display: "none"});

  $(".picture").css({"position": "relative", "width": "200px", "height": "200px", "background-image": "url(/files/default_avatar.gif)"});


  if (jQuery.browser.msie && (ie55 || ie6)) {
    $(".avatar_layer").each(function() {
        //alert(jQuery(this).css('background-image'));
        //$(this).css('background-image', 'none');
        //$(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + image.url + '\', sizingMethod=\'scale\');';
    });
}
});
}
  • 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-06-17T20:11:09+00:00Added an answer on June 17, 2026 at 8:11 pm

    Found the problem. It was caused by the HTML differing from the D6 to D7 versions of the page. There wasn’t actually anything wrong with the JavaScript and jQuery really, aside from the fact that it wasn’t compensating for that difference.

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

Sidebar

Related Questions

I am looking at Perl script written by someone else, and I found this:
I'm trying to modify a script that someone else has written and I wanted
Hey i found this pre-written jQuery script and im wondering if someone could do
I'm working with a VB Script file written by someone else that uses Windows
I've written a .NET/jQuery rating script that allows users to rate a particular product.
I was going over a Perl script written by someone else and I am
I have a script written long ago by a freelancer that's worked fine until
I have written this small script. Can someone help me fix this I have
I've written this script which pulls the sAMAccountName of the specified user from the
well i run this script , which is written to do some screenshots of

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.