Jump to content

record set duplicates


Recommended Posts

I am wondering how to filter results out of a record set. I have to find all of the "unique zip codes" in a record set and than display them. I have a start to the program where it displays all of the zip codes I'm just not sure how to filter out the duplicate so the don't show up. If I can do it as an array I think I know how to do it. I just need a little help in the right direction. Here is what I have so far.


function project5Part1() {
   //Constant Variables
   ZERO = 0;

   // Variable Declarations
   var zipCode;
   var output;
   var records;
   var count = ZERO;
   var display = "";

   // Display results
   output = document.getElementById("outputDiv");

   // Open the Zip Code Study Records and make them
   // available to the script
   records = openZipCodeStudyRecordSet();

   while (records.readNextRecord()) {
       zipCode = records.getSampleZipCode();

   // Output the results
   output.innerHTML = display + "<br />";

Link to comment
Share on other sites

I have went to many of the sites you told me about and have found great information. However I can not find out how to turn a recordset into an array. I know this is very basic, but it's just something I have missed. Here's my new code.

   This is the JavaScript code for 
   "Find Unique Zip Codes" 
   File: /unit5/project/project5Part1.html
function project5Part1() {

   var myArray = new Array();
   var sortedArrayOfStudents;
   var zipCodeRecords;
   var output;
   var arrayOfZipCodes;
   var test = "";

   output = document.getElementById("outputDiv");
   zipCodeRecords = openZipCodeStudyRecordSet();

   while (zipCodeRecords.readNextRecord()) {
   arrayOfZipCodes = zipCodeRecords.getSampleZipCode();
   myArray = arrayOfZipCodes;
   test +=  myArray + "<br />";

   output.innerHTML = test + "<br />"; //will have to fix output
   return false;

Link to comment
Share on other sites

I am not very experienced in JavaScript so bare with me If I'm out completely wrong, but as you put the next record in myArray that you later pass into the test variable before you do that check with a if-statement if the current myArray value contain in the test variable.


if (check if (not)the current myArray value contain in the test variable) {
test +=  myArray + "<br />";

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...