Posts by Daniel Mendes • 6,211 points
247 posts
- 
		0 votes2 answers55 viewsA: How to change background-color every time the page refreshes? - JavascriptOne way to do this is to record the color information in the localStorage of the browser and on onLoad of the page, read this information and change the color based on it. Example: //Evento de… 
- 
		0 votes1 answer23 viewsA: Return of an AJAX is not returning value in FunctionThe class XMLHttpRequest has an asynchronous behavior, if you put some console.log, will see that they are displayed in a different order, this helps to understand what the flow is like. Usually… 
- 
		3 votes1 answer35 viewsA: Why doesn’t the console return anything?There are some points that need to be seen: You are assigning the event click only at the first checkbox: document.getElementById('onoff').addEventListener('click', function(){ You use the method… 
- 
		0 votes1 answer60 viewsA: Error Importing Golang PackageYou imported the package, but did not put its name before the function GetFunction, to fix, type the package name before using the function, example: functions.GetFunction() In addition, it may be… 
- 
		3 votes2 answers234 viewsA: Error "Maximum recursion Depth exceeded" when implementing SetterYour code is looping, this is because its internal property nome is also a setter. So when do you do an assignment on self.nome, as is done in the class builder, he calls the @nome.setter, which in… 
- 
		2 votes1 answer46 viewsA: JSON replacing information with the same nameWilliam, To save a JSON with two properties name, you can create an array and each position of the array is an object that contains the property name and its value, example: [ { "name":"Mohamed… 
- 
		2 votes1 answer331 viewsA: Infinite registration of clientThis is because after the first time the user chooses the menu option, the variable option no longer has its value changed, and you are inside a while True. A simple fix would be to place the… python-3.xanswered Daniel Mendes 6,211
- 
		1 votes1 answer37 viewsA: Problem creating 2 n x m matrices in CWhen you declare variables n and m, they end up having values, so your matrices end up having a size even before you ask the user the size of them. See this example, just displaying the values of n… canswered Daniel Mendes 6,211
- 
		4 votes1 answer42 viewsA: Change HTML via JSTo find an element by name, you can use the method getElementsByName, but since the name is not unique, it can return more than one element, note that the name is plural. Having the elements, to… javascriptanswered Daniel Mendes 6,211
- 
		0 votes1 answer48 viewsA: scanf reading the variable twice!Luis, The problem is this space you left on scanf: scanf("%d ", &valor); Remove the same, leaving as follows: scanf("%d", &valor); See online: https://repl.it/repls/EasygoingBothDemand… 
- 
		1 votes2 answers106 viewsA: Equality comparisonComplementing the @Maniero response by using the function aScan that searches for values in the array, the equality comparison is done only with an equal sign, just by doing an Ascan as follows:… 
- 
		0 votes3 answers52 viewsA: How do I self-play and stop a video when I open and close a modalTo give an autoplay on Youtube video, you can use the queryparam autoplay, sending the amount 1: https://www.youtube.com/embed/0ArxPy04p_4?autoplay=1 See that the video is open and is already given… 
- 
		1 votes2 answers45 viewsA: What would it be like without Arrow Function?Replace the e => for function(e) : document.querySelector('.menu .backdrop').addEventListener('click', function(e) { document.querySelector('header .menu').classList.remove('open'); }); .open {… javascriptanswered Daniel Mendes 6,211
- 
		2 votes1 answer41 viewsA: Why does this code always return False?It always returns false, because the first condition will always be true, regardless of the parameter you pass. This happens on account of the following check: if ( ext === 'TXT' || 'DOC' || 'XLS'… 
- 
		1 votes1 answer315 viewsA: How to make a menu repeat itself until a variable option?Normally for situations like this, we use a loop, while the option is invalid the menu is displayed again. We can choose to do this with the do/while, which will display the menu once and if the… 
- 
		0 votes1 answer65 viewsA: Problem with dynamic delete procedure in mysqlI don’t know a native way to do that, something similar to Rest Parameter javascript, usually in this type of situation, a type parameter is created varchar that will receive all data already… 
- 
		3 votes1 answer524 viewsA: What does a SNAPSHOT version mean?A snapshot version on Maven is the one that has not been released, it is the compilation of your code at a given time. With this, it is possible to have version 1.0-snapshot, before version 1.0… 
- 
		1 votes1 answer23 viewsA: How to count records in the Onetomane relation returning zero when there is no matchHow you want to bring the table data carteira even if there are no data in the table ativo, you must use the left join: To = Wallet B = Active Soon your query will be as follows: select c.codigo ,… 
- 
		1 votes2 answers230 viewsA: When selecting a checkbox, disable other checkboxesYou can do this using the property disabled of the HTML element: function getRadiosByName(name) { return document.querySelectorAll(`[name$=${name}]`); } function marcarTodos(radio) { const itens =… jqueryanswered Daniel Mendes 6,211
- 
		5 votes3 answers116 viewsA: error in Count functionThis is happening because of the brackets you put in the variable voto before using the count: [voto].count(1) When you do this, you end up creating a new list that contains voto, and when calling… pythonanswered Daniel Mendes 6,211
- 
		3 votes2 answers265 viewsA: clearInterval not for setInterval functionThe function clearInterval must receive the return of the function setInterval, but how you encapsulated the setInterval, ended up passing the function timer as a parameter, so your setInterval will… javascriptanswered Daniel Mendes 6,211
- 
		3 votes1 answer122 viewsA: Fix an Error - JavascriptThere are some errors in its function: You redeclared the parameters umArray and outroArray with fixed values within the function: var umArray = [1, 2,3]; var outroArray = [4,5]; This is incorrect,… javascriptanswered Daniel Mendes 6,211
- 
		7 votes1 answer58 viewsA: What is the "-->" operator in C?Actually, what’s going on is x-- greater than 0, i.e., the while is decreasing x while x greater than 0: #include <stdio.h> int main() { int x = 10; while (x-- > 0) { // x goes to 0… canswered Daniel Mendes 6,211
- 
		0 votes1 answer80 viewsA: Function does not remove HTML content when input text content is removedYou can check and work with the contents of the variable hasText (event.target.value) before making the filter. If it has value, you perform the filter, otherwise you can only use the values already… javascriptanswered Daniel Mendes 6,211
- 
		0 votes2 answers104 viewsA: Concatenate string and return the number of charactersThere are some errors in its function: You used the property length with the incorrect writing, was written lenght, fixing that your function will already work. You received the parameters but did… 
- 
		1 votes2 answers56 viewsA: I can’t find the highest value in a flip-book dictionaryThis is happening because your dictionary has a list on A: a['A'] = sample(range(0, 200), 50) You can opt for some changes to your code, such as iterating the position A dictionary: for v in a['A']:… 
- 
		6 votes3 answers816 viewsA: Compare values of 2 different arrays with JSThere are several ways to compare data from an array. Whereas you have a simple array, being only a vector without complex objects, we can for example create a function and make a for, comparing… javascriptanswered Daniel Mendes 6,211
- 
		1 votes1 answer70 viewsA: Is it possible to go through all the lines of a select, through some loop in the Mysql database?What can be done is to insert on the basis of a select, for this, it is not necessary to even create a procedure. You create the structure for the insert: insert into movimentacao_acesso (idm, data,… 
- 
		3 votes1 answer39 viewsA: Correcting Error NanLike the preco is the next input after the amount (qtde), you can use the next based on it, example: var preco = $(this).next("input").next(".preco").val(); See the full code:… 
- 
		1 votes1 answer51 viewsA: Resolve syntax error by pressing enter on keyboard without typing anythingYou can treat the exception with try/except: while True: try: num = int(input('Digite um número entre 0 e 20: ')) break except ValueError: print("Digite somente números!") With this while the… 
- 
		1 votes1 answer65 viewsA: decimal division resultYou need to convert the numbers to double before division, in your example you divide the integers and only then do the conversion: resultado = (double)(a / b); To fix and have a number with… 
- 
		1 votes1 answer66 viewsA: Html2canvas file name to leave with date/timeYou can use the class Date and its methods to form a date and time in the format you want: const data = new Date(); console.log("Objeto Date:", data); console.log("Ano:", data.getFullYear());… 
- 
		0 votes1 answer77 viewsA: change the font color inside the pre tagCreate a Highlight of syntax it’s not that simple, if you just want to focus on the color part of your code syntax and not how to do it, you can choose to use a ready lib for this task. An example… 
- 
		1 votes1 answer442 viewsA: Python - Typeerror: int object is not iterableThe function sum work with objects that can’t be changed, and you’re going through a int for the same: idade = int(idades) soma = sum(idade) You can correct this passage by creating a simple… 
- 
		3 votes2 answers66 viewsA: Type number again if repeatedNotice that you take the current number typed: valoratual:= numero[i]; And in his for that checks if the number already exists, you compare it to the item that has just been typed, because its for… pascalanswered Daniel Mendes 6,211
- 
		2 votes1 answer23 viewsA: Print only the negativesYou are making an incorrect use of the function sum, sending an integer number, being that it expects an eternal object: soma_dos_negativos = sum(n) A possible correction would be to declare the… python-3.xanswered Daniel Mendes 6,211
- 
		3 votes1 answer58 viewsA: When clicking a checkbox, automatically mark other checkboxesFirst very important point, you are working with input of the kind radio and not checkbox, soon you won’t be able to select more than one. Changing your inputs to checkbox, you can use the… 
- 
		1 votes1 answer34 viewsA: Function randint does not return a valueThis is happening because of the types of variables numeroaleatorio and resposta. When you ask the user for the number, you use the function input, which returns a string, but you compare it to the… pythonanswered Daniel Mendes 6,211
- 
		1 votes1 answer68 viewsA: Select Numbers in an HTML table by table dataIf your table always follows this rule of having two tds for tr within the tbody, you can filter only this second td which has the numerical data. Here’s an example of how to do this, using the… 
- 
		2 votes2 answers250 viewsA: Print struct data with read values from a text file in CThe problem is in using the function feof, more specifically in the comparison of their return. The function feof returns 0 when the file is not in eof, and different than 0 when the file is in eof.… 
- 
		0 votes3 answers91 viewsA: Background in the tag aside hides all content inside the tagTry using the image not with the tag img, but how css: background-image: url("br.jpg"); background-size: cover; aside{ width: 50%; height: 100%; position: fixed; right: 0; top: 0; background-image:… 
- 
		0 votes1 answer369 viewsA: Save an object inside an array without overwriting the old javascriptThis happens because you always work on the variable obj, with this, you always rewrite the values of the variable and add it again in the array, as all positions of the array point to the same… 
- 
		1 votes1 answer27 viewsA: Why should this repeating structure that should turn a word upside down not come back at all?The problem is on the line you reverse the word: phrase_inverse = words_together[letra] Note that you always assign the value of the last letter read in the variable, but do not accumulate the… 
- 
		1 votes1 answer61 viewsA: C language code print pairs from one to fiftyYour logic is correct, and the result too, it turns out that you did not give spaces or did a line break between the results, so all even numbers were printed next to each other. You can edit your… 
- 
		3 votes1 answer297 viewsA: Array with negative numbers javascriptUse the filter is a good option, but it was being used incorrectly, see the correction: function numeros5(n1, n2, n3 ,n4, n5){ let ray = [n1,n2,n3,n4,n5]; return ray.filter( number => number <… javascriptanswered Daniel Mendes 6,211
- 
		1 votes1 answer728 viewsA: Place PHP tabs in HTML tableIt turns out the way you called the function tabuada, it is being interpreted as a string: $tabela .= '<td>tabuada (10)</td>'; As its function tabuada already makes the impression using… 
- 
		3 votes2 answers71 viewsA: How to prevent a function from being executed when a condition is reached and reactivate it when necessary?If you do not want the function to run completely, just check the variable value size according to its rules of maximum and minimum size: $(".dec-font").click($.diminuiFonte = function () { var size… 
- 
		2 votes1 answer86 viewsA: Python3:Kinter:Button runs aloneThis is happening because you end up invoking the method batata when creating the button:… 
- 
		4 votes2 answers349 viewsA: How to calculate the result of an arithmetic expression contained in a tuple respecting the operators' precedence?To transform a string list in Python, we can use the method join of str: valores = ('5', '+', '2', '*', '5') soma = ' '.join(valores) print(soma) With this, the values of your tuple will form a… 
- 
		0 votes2 answers684 viewsA: How to check if a directory is empty or if there is an existing file in the folder?You can use the method readdir of fs and in the callback, check if there are any files, using the length: fs.readdir(diretorio, function(err, files) { if (err) { console.error("Erro na leitura do…