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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:42:27+00:00 2026-06-02T02:42:27+00:00

I have a snippet of JQuery code that do some bar scrolling. Since I

  • 0

I have a snippet of JQuery code that do some bar scrolling.

Since I have three, four, … n bar to slide into my PHP page, I assign them dinamically an id and pass it to JQuery for be sure that my snippet slide the correct bar on a mouseOver event.

That’s the snippet of code that do the “inizialization” of my scrolls

(function($){
 $.fn.horizontalScroll = function(options) {

 var rid = arguments[0];
 var oid = arguments[1];

 var defaults = { };

 var options = $.extend(defaults, options);

 return this.each(function() {

            var horiz_scroll = new dw_scrollObj($(this).attr('id'), $(this).children().attr('id'), $(this).children().children().attr('id'));
            horiz_scroll.setUpScrollbar("dragBar_"+rid+"_offer_"+oid, "track_"+rid+"_offer_"+oid, "h", 1, 1);
            horiz_scroll.setUpScrollControls('scrollbar_'+rid+'_offer_'+oid);

As you can see, "dragBar_"+rid+"_offer_"+oid dinamically concatenates my id(s) to other string part.

That’s fine and all goin’ well, except when my oid became something like -1

In that case I have an error that says

identifier starts immediately after numeric literal

That’s confuse me, because i’ve read on StackOverflow some questions like this (just a random one) and I expect that behaviour for all concatenation that involves number.

That the snippet of code where all “breaks”

this.timerId = setInterval(this.animString + ".scroll()", 10);

Where this.animString is "dw_scrollObj.col.horiz_container_outer_55_offer_-1" while in other case (where it works) is "dw_scrollObj.col.horiz_container_outer_62_offer_234"

Anyone can explain me why this happen?

  • 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-02T02:42:29+00:00Added an answer on June 2, 2026 at 2:42 am

    You are trying to access a global variable named dw_scrollObj.col.horiz_container_outer_55_offer_-1. Some browsers will make all elements accessible by their ID like that, but it’s not recommended.

    The reason it doesn’t work in your specific case is that what you’ve written is not a valid javascript variable name. Your attempt to access a variable will be interpreted as

    dw_scrollObj.col.horiz_container_outer_55_offer_ - 1
    

    If you would instead access your object by

    document.getElementById('dw_scrollObj.col.horiz_container_outer_55_offer_-1')
    

    or

    $('#dw_scrollObj.col.horiz_container_outer_55_offer_-1')
    

    you would not have this same problem.

    For your setInterval code, that would mean

    this.timerId = setInterval("$('#" + this.animString + "').scroll()", 10);
    

    or preferably

    this.timerId = setInterval(function() {
       $('#' + this.animString).scroll();
    }, 10);
    

    If your code is in a loop, where animString will change over time, inside the context, you will need to create a new closure:

    this.timerId = setInterval((function(x) {
        return function() {
           $('#'+x).scroll();
        };
    })(this.animString), 10);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some jquery/javascript code that alters some things on document ready and when
I have some PHP AJAX code that is supposed to validate some parameters sent
I have the following snippet of code (I'm using jQuery 1.4.2): $.post('/Ads/GetAdStatsRow/', { 'ad_id':
I have a small jquery snippet that displays notification message at the top of
I have a snippet of code that creates an array clusterUniqueMarkers that stores all
I have a php function which inserts a searchbar into each page on a
I have a simple javascript (JQuery based) method that does some css magic to
I've got a javascript snippet that displays a widget on my page. There's some
I have this snippet of code that looks for the value in a select
I have the following code that simply uses a jquery ui modal dialog to

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.