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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:28:51+00:00 2026-06-14T06:28:51+00:00

i have this for loop that generates labels for each data entry in the

  • 0

i have this for loop that generates labels for each data entry in the array? what i need to do now is write an if statement to check if a certain label is clicked because only that one id has more data in it to display in the next page, for the rest of the buttons i only want an alert to pop up saying there is no data available! following is the picture of the results and actual code!

PIC:
enter image description here

i only want purchase sundry’s label’s id to go to next page the rest should throw alert!

here is code:

 $(document).ready(function() {
    $.getJSON("http://41.134.206.60/wf7_api/api/inbox/johnny", function(data){
        for(var i = 0; i < data.length; i++) {
        var high = data[i].High;
        var medium = data[i].Medium;
        var low = data[i].Low;
        var sum = high + medium + low;
        $("#showdata").html("tasks");
        $("#shownames").append("<label id="+ data[i].ProcessID +" onclick="+"redirectme();"+" style="+"text-align:center;"+"font-size:x-large;"+">"+ data[i].ProcessName +"</label><label style="+"font-size:x-large;"+">("+sum+")</label><labels class="+"lowpic"+" id="+"righty"+">"+low+"</labels><labels class="+"mediumpic"+" id="+"righty"+">"+medium+"</labels><labels class="+"highpic"+" id="+"righty"+">"+high+"</labels></br>");
        };
    } , 'json');
});​

function redirectme(){
var r = document.getElementById("76");

window.location.href = "Datapage.html";
}

what currently is happening is every label is going to Datapage.hmtl, i only want the one label with a specific id to go to the datapage.html, the rest should throw an alert? how do i get this done? i am new to this!

using cordova/html5/javascript/jquery/visual studio 2010

thanks in advance

  • 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-14T06:28:52+00:00Added an answer on June 14, 2026 at 6:28 am

    This whole section of code needs a rewrite but if you just need it to work then this is what you need to change:

    $("#shownames").append("<label id="+ data[i].ProcessID +" onclick="+"redirectme(" + data[i].ProcessID + ");"+" style="+"text-align:center;"+"font-size:x-large;"+">"+ data[i].ProcessName +"</label><label style="+"font-size:x-large;"+">("+sum+")</label><labels class="+"lowpic"+" id="+"righty"+">"+low+"</labels><labels class="+"mediumpic"+" id="+"righty"+">"+medium+"</labels><labels class="+"highpic"+" id="+"righty"+">"+high+"</labels></br>");
    

    And the handling function:

    function redirectme(processId){
        if(processId == 76)
        {
            window.location.href = "Datapage.html";
        } else {
            // write your logic to show the popup or w/e.
        }
    }
    

    I’m happy to do a fiddle for you in a way that would be much easier to maintain and change if you’re interested just drop a comment below.

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

Sidebar

Related Questions

I have a loop that can look like this: For Each article In artAll
I have a for loop that loops over one array... for i=1:length(myArray) In this
I have a loop that generates List of items with Check box to select
I have a PHP while loop that generates a table containing input tags. Each
I have this code that makes a string and then echos the loop out
I have a thread, that processes incomming messages (endless loop). For this, I use
I have a function that generates a dropdown based on a query or array
I have this loop which generates a vector Diff. How do I place the
i have a php-loop that generates different results from the database, so my output
I have a function that generates a random combination. my function looks like this:

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.