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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:25:23+00:00 2026-06-14T10:25:23+00:00

is there any reason why this wouldn’t be working? var caseString = sliderInput; var

  • 0

is there any reason why this wouldn’t be working?

     var caseString = "sliderInput";
     var theString = caseString.substring(1, 2);

I put it through the Firebug debugger in Firefox and it is giving me the error:
“invalid assignment left-hand side.”

** here is my exact code

        var elements = new Array();
        elements = document.getElementsByTagName("Input");


var allSliderInputs = new Array();
var sliderParams = new Array();
var first, last, inc, style;

for (var i=0; i < elements.length ; i++){
    var c = elements[i].className; //works fine here
    var t = c.substring(0, 2); //when it hits this line it says "invalid assignment left-hand side"

 }
  • 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-14T10:25:25+00:00Added an answer on June 14, 2026 at 10:25 am

    substring is 0-indexed so you should instead do something like this:

    var word = "slider";
    var part = word.substring(0,2); // sl
    

    Also take note that .slice() does the same thing but is actually more powerful, because it can count backwards as well as forwards.

    To solve your new problem I would suggest a few things:

    1. You need to cache your length value. The list returned by getElementsByTagName is live meaning any changes to your list while you’re looping will effect that value, so it won’t behave as you’d expect.
    2. Don’t use new Array() it’s overly fancy.
    3. You don’t need to instantiate variables that you’re going to define right after.

    Try this:

    var elements = document.getElementsByTagName("input");
    var allSliderInputs = [];
    var sliderParams = [];
    var len = elements.length;
    var first, last, inc, style, c, t, i;
    
    for (i = 0; i < len; i++) {
        c = elements[i].className; //works fine here
        t = c.substring(0, 2); 
        console.log(t);
    }
    

    This works fine for me in Firefox when run on this very page in stackoverflow:
    sample result

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

Sidebar

Related Questions

I'm trying to do this, and failing. Is there any reason why it wouldn't
Is there any reason why this shouldn't work? [PseudoCode] main() { for (int i
Is there any reason to do use block initialization, like this: x = Observer.new
Is there any reason why XML such as this : <person> <firstname>Joe</firstname> <lastname>Plumber</lastname> </person>
For 'large' tables, is there any reason not to put a filter on indexes
I don't know of any reason why this wouldn't be possible, but I'd like
Are there any good reasons for why you would include JavaScript like this: <script
is there any reason to use the post-redirect-get (prg) for a request that you
Is there any reason why the below won't work, it seems to work on
Is there any reason for calling close methods on the StreamWriter class? Why do

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.