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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:59:46+00:00 2026-05-26T07:59:46+00:00

I’m not very good yet in javascript, so I need some assistance. I started

  • 0

I’m not very good yet in javascript, so I need some assistance. I started using the jQuery Autosuggest Plugin, which allows me to add tags (somewhat like stackoverflow tagging). What I want to do is, generate a checkbox for every selected tag. For this reason, I’ve modified the plugin, so that it wraps each tag name in a <span class="tag tag_name">tag_name</span>, so It’s easier to get the tag, which I do like this: $(".tag").attr("class").replace("tag ", "");. Anyhow, I’ve written up a script, that generates a check-box, but the problem is, that it only generates a checkbox for the first tag, and it keeps generating that every 2 seconds. Also, I’m worried that the script might be a bit too much on preformance? Here is the script:

$(document).ready(function(){
    var done = {};
    $("input[type=text]").autoSuggest("get.php", {searchObjProps:"name", selectedItemProp:"name", asHtmlID: "1"});
    var timer = setInterval(function(){
        if(!done[city]){
            var city = $(".mestoJe").attr("class").replace("mestoJe", "");
            done[city] = true;
        }
        var nr = 0;
        $.each(done, function(i, j){
            if(j != 2){
                var tmp = $('<input type="checkbox" value="'+nr+'" name="city[]">'+i+'<br />');
                $("#checkboxes").append(tmp);
                j = 2;
                nr++;
            }
        });
    },2000);

});

Any help will be appreciated!

  • 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-26T07:59:47+00:00Added an answer on May 26, 2026 at 7:59 am

    In this line of your script:

    var city = $(".mestoJe").attr("class").replace("mestoJe", "");
    

    you are calling .replace() to remove the class name, but not assigning it back to anything so nothing is actually changing. .replace() returns the replaced string – it does not modify the one passed in.

    To actually change the classname and thus advance to the next city the next time the timer fires, you would have to use something like this:

    var firstCity = $(".mestoJe").get(0);
    var city = firstCity.className = firstCity.className.replace("mestoJe", "");
    

    If you don’t change the class name, then this line of code will generate the exact same result and the exact same city name every time:

    var city = $(".mestoJe").attr("class").replace("mestoJe", "");
    

    In addition, you are starting a 2 second internval timer and never stopping it so it goes on forever.

    You are also referencing:

    if(!done[city]){
    

    before you’ve ever defined city.

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

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I used javascript for loading a picture on my website depending on which small
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is

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.