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?
You could do something like this
I’ve created this fiddle and it works (if you click on “a” you get an aler, otherwise it redirects to example.com )