Results 1 to 2 of 2

Thread: Need help fixing three errors in the homework

  1. #1
    Join Date
    Jul 2014

    Need help fixing three errors in the homework

    This is the assignment below it comes back with three errors right now. I could not figure out how to fix them. Can anyone help??

       Global Variables:
          References the the table containing the filter data
          References the col elements within the filter table
          References the head section of the filter table
          References the body section of the filter table
       Function List:
       addEvent(object, evName, fnName, cap)
          Adds an event hander to object where evName is the name of the event,
          fnName is the function assigned to the event, and cap indicates whether
          event handler occurs during the capture phase (true) or bubbling
          phase (false)
       isUnique(matchValue, arrList)
          Returns a value true if matchValue is found in the array, arrList, otherwise
          it returns the value, false.
          Initiates the filter table, generating the selectin lists, and creating event 
          handlers for each select element and counting the number of records in the 
          data table
          Counts the number of visible rows in the data table
          Adds a new row to the top of the header section displaying the total
          number of records in the table
          Creates a selection list populated with option text matching the
          unique values in the table column indicated by colIndex
       addUniqueOptions(selectionList, colIndex)
          Adds option elements to the selectionList with the text of each 
          option reflecting a unique value from the data column. The index
          parameter specifies the index of the column from which the 
          option values are drawn.
          Resets the data table, displaying all table rows
          Filters the data table based on the values selected in the drop-down 
          selection lists. Also updates the record count.
       filterColumn(colIndex, fText)
          If the cell value from the current column does not equal the value
          of fText, this function hides the table row of which the table cell is part.
    function addEvent(object, evName, fnName, cap) {
       if (object.attachEvent)
           object.attachEvent("on" + evName, fnName);
       else if (object.addEventListener)
           object.addEventListener(evName, fnName, cap);
    function isUnique(matchValue, arrList) {
       var joinArray = "^"+arrList.join("^")+"^";
       var index = joinArray.indexOf("^"+matchValue+"^");
       if (index == -1) return true;
       else return false;
    var filterTable; //references web table 
    var filterCols;  //references col elements  table
    var filterHead;  //references head section 
    var filterBody;   // references  tbody element in filter table  
    addEvent(window, "load", init, false); 
    function init() {
    var filterTable = document.getElementById("filterTable");    
    var filterCols = document.getElementsByTagName("col");
    var filterHead = document.getElementsByTagName("tHead");
    var filterBody = document.getElementById("filterTable").tBodies;
    var newRow = document.createElement("tr");
    for (var i = 0; i < filterCols.length; i++) {
    var newCell = document.createElement("th");
    newCell.style.align = "left";
    newCell.style.color = "black";
    newCell.style.backgroundColor = "white";
    if (filterCols[i].className == "filter") {
    //this line has an error  
    var newSelect = createSelectionList(i);
    function countRecords() {
    var rowCount = 0;
    for (var i = 0; i < filterBody.rows.length; i++) {
        if (filterBody.rows[i].style.display == "") {
        return rowCount;
    function addTotalsRow() {
    var newRow = document.createElement("tr");
    var newCell = document.createElement("td");
            newCell.colSpan = 7; 
            newCell.innerHTML = "Matches Found: " + countRecords();
            filterHead.insertBefore(newRow, filterHead.firstChild);
    function createSelectionList(colIndex) {
    var newSelect = document.createElement("select");
    newSelect.cIndex = colIndex;
    var blankOption = document.createElement("option");
    blankOption.innerHTML = "";
    //this line which calls on a function comes back with an error
    addUniqueOptions(newSelect, colIndex);
    newSelect.width.style = "100%";
    addEvent(newSelect, "onchange", doFilter, false);
    return newSelect;
    function addUniqueOptions(selectionList, colIndex) {
    var uniqueList = new Array();
    //i get an error in the line below  
    for (var i = 0; i < filterBody.rows.length; i++) {
    var rowCell = filterBody.rows[i].cells[colIndex];
    var cellValue = rowCell.innerText || rowCell.textContent;
    isUnique(cellValue, uniqueList);
    if (isUnique == true) {
    for (var i = 0; i < uniqueList.length; i++) {
    var option = document.createElement("option");
    option.innerHTML = uniqueList[i];
    function resetTable() {
    for ( var i = 0; i < filterBody.rows.length; i++) {
        filterBody.rows[i].style.display = "";
    function doFilter() {
    var allSelects = document.getElementsByTagName("select");
    for ( var i = 0; i < allSelects.length; i++) {
    var filterIndex = allSelects[i];
        var filterText = allSelects.text; 
        var colIndex = filterIndex.cIndex; {
    if (filterText !="")  {
    filterColumn(colIndex, filterText);
      filterHead.rows[0].cells[0].innerHTML = "Matches Found: " + countRecords();
    function filterColumn (colIndex, fText) {
    for (var i = 0; i < filterBody.rows.length; i++) {
    var rowCell = filterBody.row[i].cells[colIndex];
    var rowCellText = rowCell.inndrText || rowCell.textContent;
    if (rowCellText != fText) {
    filterBody.rows[i].style.display = "none";
    Thank You

  2. #2
    Join Date
    Mar 2007
    Does help if you tell people what the three errors are rather than expect people to wade through code. What is better is for the entire web page and all the line numbers the errors appear on are included, this speeds up any pointers towards help.

    I did notice whilst indenting the above code that you have some further errors in your code and use of functions.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center