Posts by bfavaretto • 64,705 points
902 posts
-
2
votes1
answer41
viewsA: How to fix the following error: Array to string Conversion?
Since the query only returns one column, and considering that you are using PDO, you can do so: $quantidade_estoque = $stmt->fetchColumn();
-
2
votes1
answer43
viewsA: Element overlapping all the rest
First, in HTML, put your content off the canvas: <canvas id="c"></canvas> <h1 id="h1"><em>Insira o código binário</em></h1> <input type="number" name="binario"…
-
0
votes1
answer18
viewsA: Takes an input value executes function and returns in another input
Simple: retornaCpf.value = cpf_sem_ponto_e_traco; That is, to get the value you read the value of the first input, and to fill in the other you define your value.…
-
15
votes2
answers198
viewsA: How to capture the last three digits of a number in Javascript?
If the reported value is of type whole (numerical), capture the rest of the division by 1000: var n = 200100; console.log(n % 1000); If not, if the value is of the type string (non-numeric), use…
javascriptanswered bfavaretto 64,705 -
1
votes1
answer28
viewsA: Why do I still have access to the current state of the object in this case? [EXAMPLE C#]
Think about it this way: when you create an object, like this list, you get back a reference to it, which allows you to access and manipulate it. In your example, the variable itens is who keeps…
-
3
votes1
answer115
viewsA: Why should we interrupt the Promises current in recursive functions in Javascript?
You actually have memory leaking there, but the main reason is not the recursive structure - which in this case is asynchronous and indirect. The root of the problem is the behavior of the method…
-
4
votes2
answers70
viewsA: Array method not available? "Sort is not a Function" error when applying it to Nodelist
It is not an array, it is a DOM Nodelist. You can use the following: Array.prototype.sort.call(letterDivs, (a, b) => ...)
javascriptanswered bfavaretto 64,705 -
2
votes2
answers102
viewsA: CSS HOW TO CHANGE THE COLOR OF THE LINK AFTER IT HAS BEEN ACCESSED?
Use a:visited { /* estilos para links visitados */ }
cssanswered bfavaretto 64,705 -
2
votes1
answer58
viewsA: Subquery returns more than one result
Try this: SELECT IDAREAINTERESSE, COUNT(*) FROM CURSOS GROUP BY IDAREAINTERESSE ORDER BY COUNT(*) DESC
-
7
votes2
answers86
viewsA: Doubt with array and functions
You can put the dollar in front with a single loop, which changes each of the values, transforming them into "$" + original value: var x = ["hehe", "hoho", "haha", "hihi", "huhu"]; for (let i=0;…
-
1
votes1
answer221
viewsA: Access the contents of an iframe via javascript
Every window has its own document, then the document iframe is another. For your example: var iframe_document = document.getElementById('frameq').contentWindow.document; From this Document you can…
-
1
votes2
answers104
viewsA: How to dynamically remove and add HTML class with Javascript
You’re complicating too much, you don’t need any JS to underline/underline mouseover, just CSS: a { text-decoration: none; } a:hover { text-decoration: underline; } <nav> <ul>…
-
1
votes1
answer453
viewsA: Is it possible to change the parent element’s css when there is a different child?
No, it is not possible. If you want to be able to change father and son, you need to put the class in the parent element.
-
2
votes1
answer371
viewsA: You need to use ( ! defined( 'ABSPATH' ) in Wordpress
As the constant ABSPATH is set right at the beginning of the Wordpress loading process, it is guaranteed that it will exist when your theme is loaded normally. Now, imagine someone trying to access…
-
2
votes2
answers34
viewsA: php variable scope resolution
In PHP the functions are not automatically closures, so the functions do not have access to outside variables unless they are declared as global within the function, or explicitly declared as…
-
3
votes1
answer35
viewsA: Return all values of a given property in a Javascript object array
You create a new array using the method map of the original array: var people = [ { name: 'Leandro', age: 36 }, { name: 'Joaquim', age: 29 }, { name: 'Maria', age: 25 } ]; var names =…
-
7
votes1
answer57
viewsA: Take more than one element from an Array
Use Array.prototype.slice(): let numeros = [1, 2, 3]; let primeiros = numeros.slice(0, 2); console.log(primeiros); The parameters represent, respectively, the first index you want, and the indices…
javascriptanswered bfavaretto 64,705 -
0
votes1
answer23
viewsA: I want to hide the small
Do the check like this: if (display !== 'block') It needs to be done this way because the value of style.display by default comes blank - and is not affected by definitions made via CSS.…
-
2
votes1
answer35
viewsA: Is there any way to make a CSS code for a specific browser?
In the case of IE versions 10 and 11, it is possible to use a media query: @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { /* IE10+ CSS styles go here */ } Source: How to…
-
1
votes2
answers37
viewsA: How can I better log in memory allocation behavior using recursiveness in this example?
See if this log clarifies you. const yourself = { count: 0, log: [], fibonacci(n) { if (this.count === 0) this.log = []; this.count++; this.log.push(`Chamada ${this.count} - n=${n}`); console.log();…
javascriptanswered bfavaretto 64,705 -
4
votes2
answers105
viewsA: Password_verify() problem in PHP
Maybe it’s not very clear to you, but the function header does nothing but spit a string on the output, before the HTTP request body. Who handles the Location header and should do the redirect is…
-
2
votes1
answer30
viewsA: onmouseover in dropleft menu
It’s with CSS that you do it, not with Javascript: .dropleft .dropdown-menu a { display: inline-block; /* para a imagem afetar a altura do a */ } .dropleft .dropdown-menu a:hover { background-color:…
-
4
votes1
answer37
viewsA: How to obtain an element that is within two or more elements?
The selector > that you are using is for immediate descendants, ie, .main > div means a div child of an element with the main class. To catch descendants on any level, simply use a space:…
-
3
votes2
answers242
viewsA: Object orientation: what defines the identity of an entity?
the entity here is related to objects representing things within a project and not database entity. As you said, the concept is abstract. The identity of an object is what defines that it is that…
-
4
votes3
answers97
viewsA: Does Hoisting occur with the variable within the function or any other block command?
In the case of the above example can I say that Hoisting occurred with the variable n1? this because it has been moved to the execution context that contains it in case it is no longer the test()…
javascriptanswered bfavaretto 64,705 -
1
votes3
answers201
viewsA: Which destructive and non-destructive way to get the last element of an array?
The non-destructive form is the end cited by the colleague of the other answer, or direct access by the last index, if it is a numerically indexed array - if it is not, it makes no sense to speak of…
-
5
votes2
answers79
viewsA: Changing the color of HTML Elements that do not yet exist
You have already understood that the problem is to try to access an element when it does not yet exist. So why not simply leave to assign mouseover treatment at the time of creation? So: var…
-
6
votes1
answer79
viewsA: What is the difference between calling a function and returning a function?
In short, it is for this specification point: Event Handler content Attributes, when specified, must contain Valid Javascript code which, when Parsed, would match the Functionbody Production after…
javascriptanswered bfavaretto 64,705 -
3
votes1
answer129
viewsA: Does Axios take long to consume the API?
You are not waiting for the reply of the request to arrive before trying to show the data. Try so: axios.get(this.api_url(this.dom.value)).then((resposta)=>{…
-
5
votes2
answers71
viewsA: How do I declare a ternary operation for it to show on an HTML page?
Assign the expression result to a variable, and use this variable in the output: var resultado = s >= 6 ? 'Aprovado' : 'Reprovado'; res.innerHTML = `Resultado: ${resultado}`; Or, as Maniero…
-
6
votes1
answer85
viewsA: How to access, within a function, a global variable that has the same identifier as the variable within the function?
Using the same identifier is not possible as you block (shadow) access to the global variable by declaring an equal identifier within the function. The only output in this case is to declare the…
-
0
votes1
answer49
viewsA: set cursor position
It is not possible to determine the position of the cursor (mouse) relative to the screen. However it is possible to put the focus on a certain field, which seems to be what you want to know. In…
-
2
votes2
answers330
viewsA: Ciclo for javascript - unexpected result
There is no reason to loop there, the formula is not iterative. Its function can simply be: function caloriasDeTrote(numeroDeVoltas) { if (numeroDeVoltas === 1) return 5; return 5 + 5 *…
-
8
votes3
answers246
viewsA: What is a modal?
A window or dialog box modal is a user interface element that requires a response from the software operator, allowing no further action until that response is given. A classic example are the save…
-
2
votes1
answer41
viewsA: Concatenate with specific format
Instead of concatenating, you can use the FORMAT. For example: SELECT ... FORMAT(DtFimVigencia, 'yyyyMM') AS ...…
-
1
votes3
answers41
viewsA: Assign new items in an array without rewriting the whole code
Consider always having the key, but with an empty value if there are no cookies. I don’t know if I would use Curl constants to index the array, but I’ll leave it as you did. It would look like this:…
-
1
votes2
answers141
viewsA: Variable receiving only 1 single fetch value, how to fix?
The fetch only picks up one line at a time, it was made to be used in loops. It seems that you want the behavior of fetchAll. But avoid using fetchAll if it’s too much data.…
-
3
votes1
answer203
viewsA: How to destroy property of an object dynamically?
You can use the delete to remove object properties: next(){ if(ITEM_SELECIONADO !== name) return modelo.next(); delete this.modelo; return this; }…
-
0
votes2
answers49
viewsA: Doubt loop FOR in C
Are you understanding the condition of for on the contrary, as if it were a stopping condition, when in fact it would be "of continuity". That is, the semantics is execute the loop while the…
canswered bfavaretto 64,705 -
4
votes1
answer44
viewsA: What exactly does Rest syntax return, just the elements or some special object?
First of all, there’s no Rest Parameters there, and yes the Operator spread. To better understand the difference, see this answer. What it does is extract the values from the array, and pass on. I…
-
5
votes1
answer111
viewsA: Copy column data from one table to another
You need an update with Join. Something like this (untested, make a backup of the database before running): UPDATE Ordem_servicos os INNER JOIN orcamentos AS o ON o.id = os.orcamento_id SET…
-
5
votes1
answer149
viewsA: CURDATE() with day and time
The function CURDATE returns only the date, no time, so your condition is considering 00:00:00, past. You can use NOW(). The function DATE that you used is also removing the time from the other…
-
9
votes2
answers178
viewsA: What is this if trying to say?
That one if simply checks if the function elem.requestFullscreen exists, ie if the browser supports full screen. JS functions are objects, and objects are converted to true in contexts that require…
-
3
votes1
answer51
viewsA: Changing the default value of a parameter in a function is possible?
It looks like a kind of rolled-up situation, but in the scenario described I would solve by replacing the functions of the array with new ones, which envelop the originals. So: var…
-
3
votes2
answers42
viewsA: In this case am I or am I not required to declare the same variables?
You can simply call your function manually the first time: function dateUpdate() { var date = new Date(); var dateLocate = date.toLocaleString() var paragraph =…
javascriptanswered bfavaretto 64,705 -
3
votes1
answer179
viewsA: Creating Json File with PHP. Taking out last comma
This looks like a JS generated by PHP, right? To boot Datatables, if I understand correctly. The simplest and correct is to use the function json_encode PHP to generate a valid JSON from an array.…
-
0
votes1
answer47
viewsA: Movement of HTML page
You can disable the standard anchor action (either for the document itself or a normal link) in two ways. My examples will affect all the page anchors, it’s up to you to adapt the selectors to your…
-
2
votes1
answer355
viewsA: Parse error: syntax error, Unexpected ' ' (T_STRING)
You have (almost) invisible characters in your code (in space), at the beginning of each line. Remove the spaces that are at the beginning of each line. This was definitely caused by copying and…
phpanswered bfavaretto 64,705 -
3
votes1
answer52
viewsA: How to detect access denied with PHP on Windows?
Yes, you can use is_readable($caminho) to test whether the user used to run PHP has access to a file or directory. Example (from the manual): $filename = 'test.txt'; if (is_readable($filename)) {…
-
1
votes1
answer31
viewsA: Change array Response to object
Who generates the answer is the server, if you have no way to change there you only have to deal with what you receive: if (response.data.length > 0) this.data = response.data[0]; PS: You know…