Posts by Andre • 5,836 points
229 posts
-
1
votes2
answers482
viewsA: What is the difference between `UNDEFINED` and `IS NOT DEFINED`
undefined is a type of value to represent empty, similar to null. Why Javascript has two types of empty causes discussions, but the idea is that undefined is used as the default value of an…
javascriptanswered Andre 5,836 -
2
votes1
answer29
viewsA: PHP Changing a word from a variable
$nome_do_arquivo = "/wp-content/uploads/1.avi"; $str = str_ireplace(".avi", ".mp4", $nome_do_arquivo); Strings are immutable in PHP. They occupy a certain space in the memory stack, and when you try…
-
1
votes1
answer1177
viewsA: Using input file with JS
You have to buffer this image. Inputs of the type file only captures file metadata (including the URI you see in value). The (binary) file itself is only read completely when you send it through a…
-
1
votes1
answer54
viewsA: Function that returns a URL value
Return a Promise, and call the resolve of the granted value, which will be obtained when you use await. const getDadosAsync = () => new Promise((resolve, reject) => { let url = 'http://' +…
javascriptanswered Andre 5,836 -
1
votes1
answer35
viewsA: How does POST differ from PUT when dealing with existing URIS?
An HTTP request is more than a URI, it includes a header and possibly a useful load (the body). Most of this request is filled automatically by the browser, but it in its total looks like this: GET…
-
3
votes1
answer207
viewsA: Doubt when calling function in Javascript - use of parentheses
Not. botao.onclick = mostrarAlerta assigns the function mostrarAlerta to the property onclick. The function itself is the value being passed. If on the other hand you use botao.onclick =…
javascriptanswered Andre 5,836 -
0
votes1
answer38
viewsA: When the person chooses something in select display an image on the form side
Create an Event Listener in your select. Using change as a trigger, the callback function declared will be invoked every time the value of your select is changed. Then just change the source url of…
-
0
votes2
answers295
viewsA: Javascript variable inside the EJS tag
You can use <%= variavel %>, similar to PHP. <% for (var i = 0 ; i < objeto.lenght; i++ ) { %> <% if (objeto[i].index == variável_externa) { %> <%= objeto[i].nome %> <%…
-
4
votes1
answer445
viewsA: How to view the properties of an element in the console with pure Javascript?
For the Chrome browser, console.dir can be used to visualize the properties of an DOM element. According to the specification of the console.dir, this method should work for all browsers, but in…
javascriptanswered Andre 5,836 -
2
votes1
answer63
viewsA: How to loop to load Json result
You’re already using a loop, aren’t you? Don’t just nest another loop inside it? foreach ($json_data["Result"] as $data) { foreach ($data["CreditData"][0]["Addresses"] as $address) { echo…
-
1
votes5
answers2183
viewsA: Save items and recover values with Localstorage
This would not be the case to save an array instead of saving a single object to the localStorage? var saveItemCart = function(){ var cart = localStorage['cart'] ? JSON.parse(localStorage['cart']) :…
-
3
votes1
answer29727
viewsA: How to insert line break in javascript
It’s up to \n even. <br> is for breaking lines in HTML, not input values. const str = 'texto\ntexto\ntexto\ntexto' document.getElementById('ta').value = str const a =…
-
1
votes1
answer655
views -
1
votes1
answer313
viewsA: Java program to insert lower and upper bound and return the sum of even numbers from the range
for (cont = ltinf; cont <= ltsup; cont++){ if (cont % 2 == 1){ cont++; somapar = somapar + 2; } else{ for (cont = ltinf; cont <= ltsup; cont++){ somapar = somapar + 2; } } } This logic is…
-
5
votes3
answers2337
viewsA: How to count characters from a String ignoring whitespace?
length is a class method String, this method returns an integer. trim is also a class method String, but you are invoking trim on the return of length, which is an integer. Integers do not have the…
-
1
votes1
answer31
viewsA: Do not trade players
Okay, "Player" refers to HTML, but there is no manipulation in the DOM for the value displayed to the user to be changed. There is only one variable with the same name receiving values, but this…
-
0
votes1
answer43
viewsA: Error in a method exported from a module with Typescript
But abstract doesn’t mean you don’t need to use new, Abstract means that this class cannot be used directly and must be implemented by another class. To use a method without creating an object, what…
typescriptanswered Andre 5,836 -
1
votes2
answers56
viewsA: Questions on how to use javascript with visible and hidden fields
To not hide the CPF tab when the page is loaded simply... Do not hide it. You’re doing it manually with the code $(".oculto").hide(), utilize $("#info2").hide() to hide only the CNPJ. Now as to…
-
1
votes1
answer30
viewsA: Paragraph disappears quickly after executing function
You haven’t declared your kind <button>. Like he’s inside a <form>, the button ends up becoming the type submit, which means that when you click on it, the form is sent and a new page is…
-
4
votes2
answers403
viewsA: Read JSON Key with Javascript
The localStorage cannot store objects, objects are references, and references are not shared between different contexts. Once you close the page, or open a tab, this reference will not be able to…
-
0
votes2
answers69
viewsA: Limit a createelement
Find out if the widget already exists on the page with getById, and only if it does not exist, create a new element. function conteudo(btn){ var div_c = document.getElementById('item_div'); //Cria a…
-
1
votes1
answer44
viewsA: help with the split
I don’t understand the point of this. Maybe you’re trying to solve a simpler problem but decided to ask how to do it the way you imagined, which would not be ideal. To store the results 4 in 4, you…
javascriptanswered Andre 5,836 -
4
votes6
answers4637
viewsA: Dual in function and for
This "cycle" is weird. By the question I would understand that a cycle would be a season, but in the example the tree grows throughout cycle, which suggests that a cycle would be summer + autumn and…
javascriptanswered Andre 5,836 -
4
votes1
answer274
viewsA: How do I remove accents and replace spaces with: _?
Use the replace method by passing regular expressions const palavra = 'Rádio Mix_São Paulo'; const semEspacos = palavra.replace(/ /g, '_'); console.log(semEspacos); const semAcentos =…
-
0
votes2
answers376
viewsA: Add table column with javascript and condition
/*Filtra apenas os trs que possuem true como texto interno*/ let trs = $('#tablepesquisaprodutos tr').filter((i, e) => $(e).find('td:nth-child(19)').html() === 'true'); /*Encontra o…
-
1
votes1
answer133
viewsA: Keep data when click back
I will suggest an easy method, although perhaps not ideal. In the object window, exists the attribute history, which is a reference to your browsing history tab. You can store serializable…
-
0
votes2
answers62
viewsA: Comparison of lowest value in list
There’s nothing wrong with the code, maybe the error is on your list? See code running with this gigantic link: Edit You can also pick up the biggest and smallest value simply by using menor_valor =…
-
0
votes1
answer101
viewsA: Problem with array loop - Javascript
$.get is an asynchronous function, it takes a while to get the answer from your address, but the code does not wait for the function to finish to continue running. In this case, you are calling…
-
1
votes1
answer70
viewsA: Serialize form does not take the table
The Jquery serialize method only serializes values of elements with name (and that are not disabled), if you want to compare table data using serialize, you must give a name to all elements, and…