I read from an array to get my names then I want to click on the link to get the rest of the info for that person.
If you change the for loop line to be from names_array.length to names_array.length-1
the values of the last item in the arrays get passed to the function and it does not matter what link gets clicked. I need it to pass the correct values from the correct line that gets clicked.
Any help anyone can give me would be greatly apprieciated
Thanks Glen
CODE
<script language="javascript" type="text/javascript">
<!--
Expand|Select|Wrap|Line Numbers
- // Names parallel Array
- var names_array = new Array();
- names_array[0] = 'Bob';
- names_array[1] = 'Sally';
- names_array[2] = 'Henry';
- names_array[3] = 'Gerry';
- names_array[4] = 'Betty';
- // Phone parallel Array
- var phone_array = new Array();
- phone_array[0] = '555-1111';
- phone_array[1] = '555-2222';
- phone_array[2] = '555-3333';
- phone_array[3] = '555-4444';
- phone_array[4] = '555-5555';
- // Address parallel Array
- var address_array = new Array();
- address_array[0] = 'Vancouver\, BC';
- address_array[1] = 'Calgary\, Alberta';
- address_array[2] = 'Saskatoon\, Sask';
- address_array[3] = 'Winnipeg\, Manitoba';
- address_array[4] = 'Toronto\, Ont';
- for (i = 0; i < names_array.length; i++) {
- document.write('<a href="#" onclick="passNames(names_array[i], phone_array[i], address_array[i]);">Click to see Info ' + names_array[i] + ' \<\/a>');
- document.write("<hr />");
- }
- function passNames(name1,name2,name3) {
- alert(name1 + " - " + name2 + " " + name3);
- }
</script>
END CODE