function runEnter() {

    //Prevent the page from refreshing
    d3.event.preventDefault();

    //Clear out the table
    tbody.html("");

    var filteredData = tableData;

    //Select the input element and get the raw HTML node
    var datetimeElement = d3.select("#datetime");
    //Get the value property of the input element
    var datetimeValue = datetimeElement.property("value");
    console.log(datetimeValue);

    //Select the input element for city
    var cityElement = d3.select("#city");
    //Get the value property of the input element
    var cityValue = cityElement.property("value");
    console.log(cityValue);

    //Select the input element for state
    var stateElement = d3.select("#state");
    //Get the value property of the input element
    var stateValue = stateElement.property("value");
    console.log(stateValue);

    //Select the input element for country
    var countryElement = d3.select("#country");
    //Get the value property of the input element
    var countryValue = countryElement.property("value");
    console.log(countryValue);

     //Select the input element for shape
     var shapeElement = d3.select("#shape");
     //Get the value property of the input element
     var shapeValue = shapeElement.property("value");
     console.log(shapeValue);

    //Filter the data
    if (datetimeValue.length > 0) {
        filteredData = filteredData.filter(sighting => sighting.datetime === datetimeValue);
    }
    if (cityValue.length > 0) {
        filteredData = filteredData.filter(sighting => sighting.city === cityValue);
    }
    if (stateValue.length > 0) {
        filteredData = filteredData.filter(sighting => sighting.state === stateValue);
    }
    if (countryValue.length > 0) {
        filteredData = filteredData.filter(sighting => sighting.country === countryValue);
    }
    if (shapeValue.length > 0) {
        filteredData = filteredData.filter(sighting => sighting.shape === shapeValue);
    }

    //Add the filtered data only to the table
    filteredData.forEach(function(selections) {
        console.log(selections);
        // Append to the table like above
        var row = tbody.append("tr");
        Object.entries(selections).forEach(function([key, value]) {
            console.log(key, value);
            var cell = row.append("td");
            cell.text(value);
        });
    });
}
//Complete the event handler function for the form
Complete the event handler function for the form
Complete the event handler function for the form
function runEnter() {
    d3.event.preventDefault();
    tbody.html("");
    var filteredData = tableData;
    var datetimeElement = d3.select("#datetime");
    var datetimeValue = datetimeElement.property("value");
    console.log(datetimeValue);
    var cityElement = d3.select("#city");
    var cityValue = cityElement.property("value");
    console.log(cityValue);
    var stateElement = d3.select("#state");
    var stateValue = stateElement.property("value");
    console.log(stateValue);
    var countryElement = d3.select("#country");
    var countryValue = countryElement.property("value");
    console.log(countryValue);
     var shapeElement = d3.select("#shape");
     var shapeValue = shapeElement.property("value");
     console.log(shapeValue);
    if (datetimeValue.length > 0) {
        filteredData = filteredData.filter(sighting => sighting.datetime === datetimeValue);
    }
    if (cityValue.length > 0) {
        filteredData = filteredData.filter(sighting => sighting.city === cityValue);
    }
    if (stateValue.length > 0) {
        filteredData = filteredData.filter(sighting => sighting.state === stateValue);
    }
    if (countryValue.length > 0) {
        filteredData = filteredData.filter(sighting => sighting.country === countryValue);
    }
    if (shapeValue.length > 0) {
        filteredData = filteredData.filter(sighting => sighting.shape === shapeValue);
    }
    filteredData.forEach(function(selections) {
        console.log(selections);
        var row = tbody.append("tr");
        Object.entries(selections).forEach(function([key, value]) {
            console.log(key, value);
            var cell = row.append("td");
            cell.text(value);
        });
    });
}
function runEnter ( ) { d3 . event . preventDefault ( ) ; tbody . html ( "" ) ; var filteredData = tableData ; var datetimeElement = d3 . select ( "#datetime" ) ; var datetimeValue = datetimeElement . property ( "value" ) ; console . log ( datetimeValue ) ; var cityElement = d3 . select ( "#city" ) ; var cityValue = cityElement . property ( "value" ) ; console . log ( cityValue ) ; var stateElement = d3 . select ( "#state" ) ; var stateValue = stateElement . property ( "value" ) ; console . log ( stateValue ) ; var countryElement = d3 . select ( "#country" ) ; var countryValue = countryElement . property ( "value" ) ; console . log ( countryValue ) ; var shapeElement = d3 . select ( "#shape" ) ; var shapeValue = shapeElement . property ( "value" ) ; console . log ( shapeValue ) ; if ( datetimeValue . length > 0 ) { filteredData = filteredData . filter ( sighting => sighting . datetime === datetimeValue ) ; } if ( cityValue . length > 0 ) { filteredData = filteredData . filter ( sighting => sighting . city === cityValue ) ; } if ( stateValue . length > 0 ) { filteredData = filteredData . filter ( sighting => sighting . state === stateValue ) ; } if ( countryValue . length > 0 ) { filteredData = filteredData . filter ( sighting => sighting . country === countryValue ) ; } if ( shapeValue . length > 0 ) { filteredData = filteredData . filter ( sighting => sighting . shape === shapeValue ) ; } filteredData . forEach ( function ( selections ) { console . log ( selections ) ; var row = tbody . append ( "tr" ) ; Object . entries ( selections ) . forEach ( function ( [ key , value ] ) { console . log ( key , value ) ; var cell = row . append ( "td" ) ; cell . text ( value ) ; } ) ; } ) ; }
Complete the event handler function for the form
Complete the event handler function for the form
//Prevent the page from refreshing //Clear out the table //Select the input element and get the raw HTML node //Get the value property of the input element //Select the input element for city //Get the value property of the input element //Select the input element for state //Get the value property of the input element //Select the input element for country //Get the value property of the input element //Select the input element for shape //Get the value property of the input element //Filter the data //Add the filtered data only to the table // Append to the table like above