Posts by bfavaretto • 64,705 points
902 posts
-
1
votes2
answers211
viewsA: Directory index Forbidden
Your server is prohibiting the listing of directory contents. To enable the listing, include this in your archive .htaccess: Options +Indexes
phpanswered bfavaretto 64,705 -
6
votes3
answers1864
viewsA: How to return key of object with higher value in Javascript?
There is no native function for this, so you will need to check all values to find the largest: var obj = {"frutas": 50, "vegetais": 100, "carnes": 150 }; var maior = -Infinity; var chave; for(var…
-
2
votes2
answers1528
viewsA: How to create validation with special characters
You need to include these characters in the list of what is accepted (the part between [ and ]). As in your list some characters have special meaning in regular expressions, it is necessary to…
-
8
votes3
answers632
viewsA: Replacement for TAG <center>
The text-align only serves to align elements inline or inline-block. The Divs by default are blocks, so are not affected by this property. You can center a div horizontally by defining its left and…
-
5
votes3
answers137
viewsA: Problems with WHERE IN (many records)
You may have performance problems, yes, but that also depends on other factors. I don’t know where the values you filter come from, but if they come from another table it might be better to use one…
-
7
votes1
answer2701
viewsA: Javascript: how to count the characters of an html text?
The solution is much simpler than you think. You don’t need to delete tags, just take their text with the property textContent: var elemento = document.querySelector('div'); // compatibilidade com…
-
4
votes1
answer5306
viewsA: How to change the innerHTML of a DIV, since there are other elements within it that cannot be changed?
If the internal element is with the class widget-content, do so: document.querySelector('#Attribution1 .widget-content').innerHTML = 'sei lá';
-
4
votes2
answers1749
viewsA: Turn string into number
Although you are using jQuery to pick up the attribute, this is standard behavior of the Javascript language. When using the sum operator between a number and a string, the number is converted to…
-
8
votes2
answers811
viewsA: HTML5 form validation
Validation does not block fields, just check their invalid status. If you change the invalid field style, this will be visible: input:invalid { background: red; color: #fff; } <form> Codigo:…
-
5
votes4
answers22158
viewsA: How to add row spacing to a table?
A much better solution than my previous one: use the border-spacing, and compensate for the side effects by fiddling with the table position and left edges of the cells (or right edges, whatever):…
-
4
votes4
answers22158
viewsA: How to add row spacing to a table?
If you accept to deal with one fixed layout, with predefined cell widths, it is possible to obtain this visual result by stacking two tables: table { border-collapse: collapse; table-layout: fixed;…
-
3
votes2
answers922
viewsA: Change Css with javascript when clicking
Every time you click, you’re creating a new Listener click that determines the margin as -230px. Solve with a single event handler. One of the ways is to toggle the margin values according to the…
-
118
votes4
answers82811
viewsA: What is and what does a full stack web Developer do?
It’s the one who deals so much with the back-end (the server side), as for the front-end (the side of customers, browsers). The back-end involves at least one programming language, and usually a…
terminologyanswered bfavaretto 64,705 -
3
votes3
answers273
viewsA: What can change with the variadic Function implementation?
I do not follow closely the developments of PHP, but the little I see passes the impression that they are quite conservative, and that even when something is marked as obsolete (deprecated) it can…
-
7
votes2
answers433
viewsA: What is the difference between the union of an array via soma operator and the array_merge function?
Considering the arrays $a and $b, the differences in the result of array_merge($a, $b) (merger) and $a + $b (union) will be: In the merge, the values of the numeric keys existing in both will be…
-
0
votes2
answers334
viewsA: Error reading dynamically generated JSON with file_get_contents
As @Rodrigorigotti said in his comment, do file_get_contents of a PHP file brings its source code, not the processed file. According to this reply in English you have two options to solve this: Make…
-
5
votes1
answer137
viewsA: How can I make an object if 'auto-delete' in Javascript?
You can simply define all references to the object as null: a = null; But it needs to be all the same. For example: var b = a; a = null; b = null; // não esqueça! Related question: How the…
-
26
votes3
answers204336
viewsA: What is the difference between asynchronous and synchronous communication?
For those who want to understand the difference at the conceptual level, without going into technical details, goes well a metaphor. Synchronous communication is like a radio conversation In a VHF…
-
9
votes3
answers2397
viewsA: Why does "Return false;" in a click event cancel the link opening?
The @Maniero already gave a good general explanation, it is the same: it was agreed that the return false cancels the default behavior of the element (in the case of clicking an anchor, follow the…
-
3
votes1
answer337
viewsA: How to merge a file with several other files, dynamically using Grunt?
To concatenate the files, you need to include the option concat in his Gruntfile: concat: { options: { separator: ';' }, dist: { src: ['dev/*.js'], dest: 'js/tudojunto.js' } },…
-
4
votes1
answer36
viewsA: A constant eventListener, or almost that
The solution to this is not to add the listeners in elements that will be removed/replaced (or that do not yet exist), but in an element prior to them in the hierarchy, whose existence is guaranteed…
-
4
votes1
answer681
viewsA: How to use ternary operator to determine what to display?
Thus: var online = resposta["IEconItems"]["570"]["online"]; $("#dota2-statusapidota").html(online === 1 ? "online" : "offline"); I put the original data in a variable to make it easier to read. The…
-
2
votes1
answer519
viewsA: 2 arrays in foreach
If they are two "parallel" arrays, numerically indexed, and with corresponding indexing, just loop one of them, and use the same index in the other. For example: foreach ($image as $indice =>…
phpanswered bfavaretto 64,705 -
1
votes2
answers1309
viewsA: Highlight selected row of the table
I didn’t quite understand the reason for your mix of jQuery with pure JS, but anyway I believe it solves: $(input).closest('tr').css('background', '#e1e1e1');
-
2
votes2
answers2142
viewsA: Problem when comparing hours
You need both conditions to be met: if($horario >= $abertura && $horario <= $fechamento){ // VEJA --- ^^ The && in place of || ensures this. In your code, one of the conditions…
-
2
votes2
answers1807
viewsA: header(" Location:") Redirect from root directory
I don’t understand exactly what you’re doing, but do it like this: header("Location: /Home/Pagina.php");
phpanswered bfavaretto 64,705 -
12
votes1
answer452
viewsA: jQuery does not use the HTML5 dataset on the date?
Based on this example, we can state that jQuery DOES NOT use jQuery dataset HTML5? Yeah, the jQuery does not use the dataset. This can be proven by looking at the source code library. there’s some…
-
10
votes3
answers3350
viewsA: Add event to multiple elements without being inside a for loop
making a function within a loop is bad practice, plus it can cause some performance problems There is some truth in these assumptions, but there is also a very big misunderstanding. You need to…
-
5
votes2
answers448
viewsA: How to use class variable as default value in php functions?
You cannot do this, the standard values of parameters need to be constant. The most PHP allows is to use class constants, with static reference: class Teste { const VARIAVEL = 10; const VARIAVELA =…
phpanswered bfavaretto 64,705 -
2
votes2
answers457
viewsA: Changing the innerHTML of a tag
This error occurs because you are trying to change the src an element that was not found on the page. And it was not found because the line that trial create it is wrong. You need to use innerHTML…
-
1
votes1
answer83
viewsA: Ignore data type check when using $.inArray
What must be converting the string value to Number is the .data, which is a jQuery function that confuses people a little bit. It was not made simply to read/write values of data-Attributes, and yes…
-
3
votes2
answers1301
viewsA: Add input button to select
The elements <option> do not accept HTML, only text. If you want to create a dropdown with visually more sophisticated options, you will need to simulate your own <select> using other…
htmlanswered bfavaretto 64,705 -
6
votes2
answers1244
viewsA: How to employ multithreading with Rduino
Arduino doesn’t support multithreading, but I’ve heard of libraries that simulate it. However, the simplest is not to use delays (which actually leave the program "deaf and dumb"), and calculate…
-
5
votes2
answers1022
viewsA: How to get the return of an instantiated Function (new + Return) - Javascript
This is not possible. You are using the function as a constructor, so it returns the object being created when invoked with new (unless you return another object, but there doesn’t even make much…
-
4
votes1
answer134
viewsA: Transmit information without going through the server
The simple and quick answer would be nay. At least not using a browser, without both users having a specific application for this purpose installed on their computers. However, as the…
-
7
votes4
answers955
viewsA: How does Current function work?
I don’t think the manual is wrong, just incomplete. I’m not familiar enough with the PHP source code to be able to trace the problem to the point where the error message is sent, but I believe I…
-
5
votes1
answer270
viewsA: What is the concept that involves the tools/workflow front-end?
I don’t quite understand your doubt, but I think this answer might help you find a way. It’s nice to have this thirst for new technologies, but you don’t have to go around using everything that’s…
-
4
votes1
answer225
viewsA: Function $.getJSON returns Undefined
Its function baixarCapa returns undefined because you do not specify any return on it. You specify return on a callback passed to her, but he only runs later (it is asynchronous), and it is not…
-
70
votes1
answer4219
viewsQ: What are the advantages of using the right HTTP methods?
I have seen many people defending the use of HTTP methods correctly, that is, respecting the semantics of the methods defined in the specification when making a request. GET should only be used to…
httpasked bfavaretto 64,705 -
9
votes2
answers4285
viewsA: Just read the first character of a string
You can read the first character passing its index, as if it were an array: $myrow['Noticia'][0] Note: the $myrow['Noticia'][0] will generate a warning (notice) if the string value is null.…
phpanswered bfavaretto 64,705 -
4
votes1
answer238
viewsA: What does this definition of resource really mean?
Terminological confusions like this are common, especially with such broad terms and in the context of the web, whose specifications always succeed the use itself, and not the other way around. At…
-
0
votes2
answers1333
viewsA: How to query data from two related tables?
I’m not sure where you’re confused, but the query should be this: SELECT dados.nome, origem.nome_cidade as origem, destino.nome_cidade as destino FROM dados INNER JOIN cidades origem ON origem.id =…
-
1
votes2
answers740
viewsA: Call javascript onsubmit does not "hold" the Submit until it gives confirmation of shunning
You can’t use it onsubmit="sweetalert(1)". The only way to expect a boolean return on onsubmit is using the confirm native (ugly and confused), which is synchronous (meaning that it "traps" the flow…
-
2
votes1
answer237
viewsA: Javascript does not accept variable value
If you look at plugin documentation, will see that colModel does not expect an array as you are passing, but rather an object. You can pass colM directly, without wrapping an array: function…
-
4
votes3
answers1491
viewsA: Add field at position I want in sql server
As already said, this type of change requires that the table be recreated. You need to authorize Management Studio to do this: Image origin: https://stackoverflow.com/a/12582648/825789…
-
4
votes1
answer1952
viewsA: Query the database send and use javascript
You have an array of objects. Brackets define the array, and each pair of { and } sets an object (one for each record). You access the records by looping the array: $.post('envia.php', {nome: nome},…
-
3
votes2
answers231
viewsA: Read phpMyAdmin column with multiple records
If the goal is to make a JOIN with another table, Mysql offers a shortcut which is the function FIND_IN_SET. But she has performance problems, the correct thing would be to model the bank in another…
-
4
votes1
answer407
viewsA: ASC and DESC sorting without losing variable value
When you load the page by changing the window.location.href, you make a request of the type GET, and not POST. But in PHP you are looking for the value in $_POST. If you always use GET (that is, if…
-
4
votes2
answers7594
viewsA: How to use the $.ajax function date parameter
Send an array of objects: var token = "Xke; var jsonTipo1 = "{ tipo: 1, numPagina: 1 }"; var jsonTipo2 = "{ tipo: 2, numPagina: 1 }"; var dados = [jsonTipo1, jsonTipo2]; // colocando ambos numa…
-
7
votes2
answers395
viewsA: It is possible to return a vector to a javascript
The data comes back on callback of the method $.post: $.post('envia.php', {nome: nome}, function(dados) { // use os dados aqui // o uso exato vai depender do formato que o PHP // usou para…