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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:00:49+00:00 2026-05-23T03:00:49+00:00

I have an array in JavaScript as follows: <script type="text/javascript"> var array1 = Array(0,1,2,3,4,5);

  • 0

I have an array in JavaScript as follows:

<script type="text/javascript">
var array1 = Array(0,1,2,3,4,5);
</script>

I have six table cells (<td>s) as follows:

<td class="title" id="title1">
<td class="title" id="title2">
<td class="title" id="title3">
<td class="title" id="title4">
<td class="title" id="title5">
<td class="title" id="title6">

I need an onclick go to URL solution. As you can see, The cells have 6 ids, from title1 to title6. The cell have to first look for its corresponding values in the array.. (0 for title1, 1 for title2 etc..). The corresponding values, as you can see is calculated using array[titlenumber-1]. If corresponding array number is greater than 0, the page may go to www.example.com when user click the <td> and if the number is less than or equal to 0, the page may alert the user "DATA ERROR". How can I do this using JavaScript and jQuery?

  • 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-23T03:00:50+00:00Added an answer on May 23, 2026 at 3:00 am

    You could do something like this

    var array1 = Array(0,1,2,3,4,5);
    
    $('td').click(function(){
    
        var id = $(this).attr('id');
        var index = parseInt(id.substr(5, id.length), '10');//take off title
        index -= 1;
        if (array1[index] > 0){
            window.location = 'www.example.com';
        }else{
            alert("data error");
        }
    
    });
    

    I’ve created this fiddle and it works (if you click on “a” you get an aler, otherwise it redirects to example.com )

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

Sidebar

Related Questions

In javascript I have an array as follows: var foo = [2, 2, 4,
I have an external JavaScript that contains: function random_imglink(){ var myimages=new Array() myimages[1]="http://sevir.sitegoz.com/jchs/Banner1.png" myimages[2]="http://sevir.sitegoz.com/jchs/banner2.png"
I have a JavaScript function as follows: function popup(username) { var req = createAjaxObject();
I have an array I've created in JavaScript. The end result comes out to
I'm creating my own JavaScript Array-like object and I have methods that call closures.
I have a one-dimensional array of strings in JavaScript that I'd like to turn
I have been playing with javascript arrays and I have run into, what I
I have an array in Perl: my @my_array = (one,two,three,two,three); How do I remove
I have an array of numbers that potentially have up to 8 decimal places
I have an array of a few million numbers. double* const data = new

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.