Skip to main content

Posts

"Uncaught TypeError: document.getElementById(...) is null" Error in JavaScript [duplicate]

I am currently learning JavaScript and I have a problem in my function(s). It's a code that convert a specific amount of EUR / USD / YEN in the other currencies and paste them in a table. I'll paste the css-code too for the optics. Important: The Program is not finished yet, you need to start the function in your browser console, it won't work automatically Example for the console: EURUmrechnen(amount) function EURInUSD(EUR) { /* The calculation of the currencies */ return EUR * 1.0537; } /* --- */ function EURInYEN(EUR) { return EUR * 135.277; } /* --- */ function USDInEUR(USD) { return USD * 0.9485; } /* --- */ function USDInYEN(USD) { return USD * 127.7625; } /* --- */ function YENInEUR(YEN) { return YEN * 0.007393; } /* --- */ function YENInUSD(YEN) { return YEN * 0.007826; } function EURUmrechnen(EUR) { /* This EUR-Calculator works as it should. */ document.getElementById("USD-Eingabe").value = EURInUSD(EUR); document.getElem

Dates not importing to SQL database correctly from Python

I have the following (subset of a) Pandas dataframe that I am trying to upload to a MySQL database: Here are details of the data using the info() function: For added context, I previously converted both the tourn_date and date column to a datetime format using this code: pd.to_datetime(all_data['tourn_date']).dt.date Finally, here is the code that I'm using to import the data into the MySQL database: for index, row in all_data.iterrows(): inserts = [row.tourn_id, row.year, row.round_num, row.tourn_date, row.date] cursor.execute("""INSERT INTO AllPlayerStats (TourneyID, Year, RoundNum, TourneyDate, TDate) values(%s,%s,%s,%s,%s)""", inserts) db.commit() cursor.close() However, when I run this, some of the dates (like the ones shown above), are appearing as NULL in the database (see below) despite other tournaments working just fine and the format of the TourneyDate and Date columns in t

React.js: How to prevent wasted renders when inserting a new form field on the page

I have a form with a couple of conditionally rendered fields. The form is made up of MUI components, react-hook-form and yup for its validation. Additionally, I have added a console.log() within the AutocompleteCoffee , RadioBtnGroup , TxtField components that will execute every time the components are rendered. Scenario When the page loads you can see a log from each component. Nothing new here. When you select "Yes" from, Do you like coffee? a new field will be rendered. This action triggers a rerender of all the components on the page. I am using the watch method from react-hook-form to keep track of the question mentioned above. const coffee = watch("coffee", "No"); ... {coffee === "Yes" ? ( <AutocompleteCoffee required fullWidth name="coffeType" label="Which coffee type" control={control} options={coffeList} error={!!

Show the Odd and Evens of a Input

I need help with an exercise in my JavaScript course. Here is the utterance: Create a program that reads the start and end values ​​of a range and prints all odd or even values ​​contained in the range. The user must be able to choose between odd and even. Show the result on the screen (not in the console.log). Also show how many numbers in the sequence are even and how many are odd. Via Active questions tagged javascript - Stack Overflow https://ift.tt/pNBYJOw

FInd duplicates on output

I submit some data via AJAX post and when I get receive response I output it via a loop. $.each(data, function() { $("#em").append('<i class="bi bi-pin-map-fill'+(lat == this.lat && lon == this.lon ? " bg-danger" : "")+'"></i> '+this.lat+' '+this.lon); let lat = this.lat, lon = this.lon; } In some case the coordinates I receive could be of the exact same location, so I'd like to be able to mark those duplicates by adding background color. So I've added a condition to check for matches but am blanking how to implement it, since I can't really set the vars at the end of my loop... Need some nudge in the right direction. Via Active questions tagged javascript - Stack Overflow https://ift.tt/2h9x0vs

Return to input if input is incorrect [duplicate]

Not sure how to return to input if the input is not a prime number until it is. num = int(input("Enter a number: ")) flag = False if num > 1: for i in range(2, num): if (num % i) == 0: flag = True break if flag: print(num, "is not a prime number") else: print(num, "is a prime number") source https://stackoverflow.com/questions/72310586/return-to-input-if-input-is-incorrect

Cant show my features in openlayers. Does someone know how to solve this?

I have been struggling with my projections for a few weeks now. At the beginning I could show my features but they appear in jemen (they are supposed to be in Italy). After I realised my coordinates were being inversed, for example my coordinate [41.18702782291,15.450187402143] (which is in Italy) was displaying in [15.450187402143, 41.18702782291] (which is in jemen), I decided to invert the coordinates of the multipolygons of my geometries so that now I have the [15.450187402143, 41.18702782291] format. I don´t know what happened but now I cant see my features shown in the map. I have an object geojson with my features and this is my code: var myview = new View({ center: [15.450187402143, 41.18702782291], projection: 'EPSG:4326', zoom: 6 }) var mylayer = new TileLayer({ source: new OSM() }) var layer = [mylayer] const map = new Map({ target: 'map', layers: layer, view: myview }); const vectorSource = new VectorSource({ format: new ol.format.Geo