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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:00:15+00:00 2026-06-02T18:00:15+00:00

I’m working on a window that has a bunch of elements that can each

  • 0

I’m working on a window that has a bunch of elements that can each be edited separately and at the same time. I use ajax to bring over the editting layout then ajax again to change it back to how it will be displayed to customers. The thing is, I want each of the “open for editing” elements to get saved when the user clicks the window-wide save button.

Now, some guy decided it’d be fun to use anchor tags around images instead of onclick functions on them so I have to use eval to call the functions.

here’s the code i’m using for the window-wide save button.

var as = document.getElementsByClassName('link_salvare');
alert(as.length);
for(var i = 0; i < as.length; i++) {
    alert(i);
    eval(as[i].href);
}
alert('finished');

the alerts are just there to see where it’s going wrong and it turns out the for structure just stops after the first iteration (i=0). I get as.length as 2 (when I have 2 “editing” elements) but then I only get i=0 then ‘finished’.

I tried with both asynchronous and non-asynchronous ajax calls and using asynchronous calls I get the above result while using the synchrronous calls I just get the alert and none of the elements are saved.

I could arrange so that only one element is ever edited at a time but that would have to wait until after the weekend to get clearance to change the individual save functions.

While this particular problem hasn’t been fixed, I work around it by

a) changing from <a href="javascript:function"><img> to <img onclick="function"> in order to avoid using eval;

b) changing the design of the window so that only one element can be edited at any time.

I still have no idea why the ‘for’ loop only went trough one interation but I don’t have time to investigate right now, best I can do is hope it doesn’t bite me in the ass later;

  • 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-02T18:00:17+00:00Added an answer on June 2, 2026 at 6:00 pm

    To touch on the eval()…. and with that said I don’t see any other issues.. you talk about ajax (XmlHttpRequest) yet you have provided no errors or code associated with it.

    HTML

    <a href="javascript:foo()" class="foobar">yoyo</a>
    <a href="javascript:bar()" class="foobar">yoyo</a>​
    

    Javascript

    var elements = document.getElementsByClassName('foobar');
    
    function foo() {
        alert('foo');
    }
    
    function bar() {
        alert('bar');
    }
    
    [].forEach.call(elements, function(element) {
        var func = element.href.split(':')[1],
            func_name = func.substring(0, func.lastIndexOf('('));
        window[func_name].call();
    });​
    

    I do highly suggest you alter the HTML source and not hack a solution like this. http://jsfiddle.net/rlemon/4vgPn/2/

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.