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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:02:44+00:00 2026-05-23T13:02:44+00:00

Firing events on every form field, I start a data control using prototype functions.

  • 0

Firing events on every form field, I start a data control using prototype functions. If it finds the type of field of the current object id obj.id among an array contents listdatatypes, then it proceeds further to some regex controls (of course, there is a php overlayer but no Ajax as I’d like to avoid recoding everything).

This works like a charm, but I’m wondering how to interrupt the propagation of the array needle search (eg the so called prototype 2) once the needle has been found.

Here is the code principle :

// proto 1
if (!String.prototype.Contains) {
    String.prototype.Contains = function(stack) {
        return this.indexOf(stack) != -1;
    };
}

// proto 2
if (!Array.prototype.forEach) {
  Array.prototype.forEach = function(my_callback)
  {
    var len = this.length;
    if (typeof my_callback != "function")
      throw new TypeError();

    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this)
          my_callback.call(thisp, this[i], i, this);
    }
  };
}

// ... main code abstract

          function str_search(element, index, array){
         // Store the found item ... and would like to stop the search propagation
             if (element.Contains(obj.id) )
                stored_id = obj.id;
          }
          listdatatypes.forEach(str_search) ;


// ...

Thx

  • 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-23T13:02:45+00:00Added an answer on May 23, 2026 at 1:02 pm

    If you’re asking if a forEach loop can be broken, the answer is no.

    You could set a flag in the function you pass it to disable the main part of the code, but that’s about it. The loop will continue until the end.

    If you want to break the loop, use a traditional for loop instead, or write a custom forEach type of method that can be broken based on the return value of your function argument.


    EDIT:

    Here’s a while that breaks when you return false.

    Array.prototype.while = function(my_callback) {
        var len = this.length;
        if (typeof my_callback != "function") throw new TypeError();
    
        var thisp = arguments[1];
        for (var i = 0; i < len; i++) {
            if (i in this) {
                var ret = my_callback.call(thisp, this[i], i, this);
                if (ret === false) {
                    break;
                }
            }
        }
    };
    

    your code:

    function str_search(element, index, array){
         if (element.Contains(obj.id) ) {
            stored_id = obj.id;
            return false;
         }
    }
    listdatatypes.while( str_search );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Windows Forms to start a System.Timers.Timer to fire an event every 3
Before you start firing at me, I'm NOT looking to do this, but someone
I am firing an Ajax request using jQuery. During the process, I show a
How might a person simulate firing the HttpSessionListener.sessionDestroyed object in a session listener? Is
I have a PictureBox control on a Form that is supposed to draw something
I was using two TButton components on a form that functioned as Plus and
I have an ATL ActiveX control that raises three events (Connected, Authenticated, Disconnected) which
jQuery is firing on every mousemove event for me. How do I get it
I have encountered a slightly bizarre bug while using the ajax control toolkit TabPanel.
A JComponent of mine is firing a mouseDragged event too vigorously. When the user

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.