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

  • Home
  • SEARCH
  • 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 765509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:53:55+00:00 2026-05-14T16:53:55+00:00

I have a script that checks the class (integer) of a , runs a

  • 0

I have a script that checks the class (integer) of a , runs a switch statement to change that integer value to text and appends the text to another in the same listitem tag. I use the .each() function because each listitem starts with class=_[user ID] — each user can have up to 5 entries.. Enough explaining — heres the code:

  <HTML>
    <li class='_44074'><div class='_12' style='width:380px;'><div style='width:60px; float:left;'>1st</div><div class='verify-type' style='float:left; width:160px;'></div><div style='float:left; width:120px;'>04/26/10 07:29 AM</div></div></li>
    <li class='_44074'><div class='_6' style='width:380px;'><div style='width:60px; float:left;'>2nd</div><div class='verify-type' style='float:left; width:160px;'></div><div style='float:left; width:120px;'>04/23/10 03:29 PM</div></div></li>
    <li class='_44074'><div class='_12' style='width:380px;'><div style='width:60px; float:left;'>3rd</div><div class='verify-type' style='float:left; width:160px;'></div><div style='float:left; width:120px;'>04/23/10 03:18 PM</div></div></li>
    <li class='_44074'><div class='_2' style='width:380px;'><div style='width:60px; float:left;'>4th</div><div class='verify-type' style='float:left; width:160px;'></div><div style='float:left; width:120px;'>04/23/10 02:28 PM</div></div></li>
    </HTML>

when I use the .each() function to scan through each of the listitems begining with the entered user id it only finds the first value (in this case _12) and applies that to all the entries; instead of finding _12, _6, _12, _2 it finds _12, _12, _12, _12…and applies the switch value “Shoe Straps & Wrist Straps” to all entries — here is the java:

 $("div#history-menu div#history-text li." + valueid).each(function(){
            valueid = $("div#center-box input").val();
    checkedvalue="";
    checkedvalue = $("div#history-menu div#history-text li." + valueid + " div").attr('class');
    switch(checkedvalue){
        case '_2':lcCheckedMessage = "Shoes"; break;
        case '_4':lcCheckedMessage = "Shoe Straps"; break;
        case '_6':lcCheckedMessage = "Shoes & Shoe Straps"; break;
        case '_8':lcCheckedMessage = "Wrist Straps"; break;
        case '_10':lcCheckedMessage = "Shoes & Wrist Strap"; break;
        case '_12':lcCheckedMessage = "Shoe Straps & Wrist Strap"; break;
    };
    $("div#history-menu div#history-text li." + valueid + " ." + checkedvalue + " .verify-type").text(lcCheckedMessage);
});
  • 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-14T16:53:56+00:00Added an answer on May 14, 2026 at 4:53 pm

    This line:

    checkedvalue = $("div#history-menu div#history-text li." + valueid + " div").attr('class');
    

    will perform the search again, always finding the first item. Instead, use the value of this to get the current item:

    checkedvalue = $(this).find('div').attr('class');
    

    You need to do something similar in the last line, e.g.

    $(this).find(".verify-type").text(lcCheckedMessage);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 432k
  • Answers 432k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Some CSS only Accordin here http://www.webdeveloperjuice.com/2010/05/17/8-powerful-pure-css-accordions-to-make-web-application-lite-and-impressive/ And it is IE… May 15, 2026 at 2:31 pm
  • Editorial Team
    Editorial Team added an answer system function is restricted in safe mode. You can only… May 15, 2026 at 2:31 pm
  • Editorial Team
    Editorial Team added an answer action is simply the URL that the form is submitted… May 15, 2026 at 2:31 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.