Posts by bfavaretto • 64,705 points
902 posts
-
6
votes3
answers954
viewsA: How to list variables defined within a Javascript scope?
This is not possible in Javascript, because the objects where the variables are stored (Environment Records) are not available to the language user except in the case of the global object. But even…
-
4
votes1
answer204
viewsA: Convert objects: from literal syntax to prototype types
The only way to exchange the prototype of an existing object is with the non-standard property __proto__, which in practice has very good support. In the next version of Javascript (Ecmascript 6),…
-
1
votes1
answer114
viewsA: Coffeescript/Javascript return/scope problems
The problem is that $.get is an asynchronous function, and therefore its method busca_estados_por_pais returns before the result of the ajax request arrives. The most recommended solution is to…
-
7
votes3
answers2326
viewsA: CSS Transition top
Simply define top: 0 in the same rule where you define the transition. Both "ends" of the transition need to be defined, and you only set the end: .hand .card { position: absolute; transition: top…
cssanswered bfavaretto 64,705 -
2
votes1
answer1707
viewsA: Place border in split div
This is because the div has floating content, which is disregarded in the calculation of dimensions. Add overflow: hidden to solve: .divCaixa { border: 1px solid #d5d5d5; padding:20px 20px 20px…
-
10
votes1
answer4141
viewsA: How to load js scripts dynamically?
No need for Ajax, just create a type element script and Research in the DOM: var script = document.createElement('script'); script.src = ""; // URL do seu script aqui…
javascriptanswered bfavaretto 64,705 -
5
votes2
answers48943
viewsA: How to change the color of a single link?
Build a css selector that reaches only the link you want to color, and create the following rule in your CSS: seu-seletor { color: #f00; /* vermelho - troque para a cor que quiser */ } The shortest…
-
20
votes2
answers8317
viewsA: How to delete a variable in Javascript?
No way to delete variables declared with var The function of the operator delete is to exclude properties of objects, not variables. Therefore in principle it would not serve to exclude variables.…
-
1
votes2
answers146
viewsA: Text problem cut when creating text file
Use htmlentities: echo htmlentities($suaString); This is only when displaying (it seems that there is your problem). In the text file, your string should be saved without escaping anything.…
-
11
votes2
answers17329
viewsA: What does "!" (exclamation) mean before a code snippet?
Anything you put inside a if(aqui) will be transformed into true or false. The body of if only executes if the result is true. Let’s simplify your example by keeping the result of Equals in a…
-
11
votes4
answers1531
viewsA: How to assign a value to an Enum with binary notation?
Considering NULL’s response to the lack of literal binaries, I suggest using the following to improve the readability of enum: public enum Direction { None = 0, //0000 Left = 1, //0001 Right =…
-
4
votes1
answer275
viewsA: Migrating Windows Local Development Environment to Mac
Installation and Setup: It’s exhausting, more complex, and requires more advanced levels of Mac usage knowledge? Apache and PHP are already installed on the Mac by default. If you want to replace…
-
8
votes1
answer876
viewsA: Combination of 4 numbers in Mysql
Kind of weird to need to do this in SQL, but having a table with the digits, just do a CROSS JOIN with herself: SELECT CONCAT(d1.digito, d2.digito) FROM digitos d1 CROSS JOIN digitos d2 WHERE…
-
3
votes3
answers201
viewsA: Internet Explorer Mode Patterns
The simplest way, not only in IE but in any browser, is to use the HTML5 doctype at the top of your document: <!DOCTYPE html>
internet-exploreranswered bfavaretto 64,705 -
8
votes2
answers478
viewsA: How do I get a loose number in my HTML?
You can cross the DOM instead of using regex, it’s much faster to process. Do the following: Find the <span> containing "Número" and, for each one: Access his father’s knot (parentNode) and…
-
10
votes1
answer789
viewsA: Download text from a textarea as a server-side language-free file
There is no ideal way to do this only on the client side. We browsers that support data Uris, you can do so: function downloadFile(conteudo) { window.location.href =…
-
1
votes2
answers232
viewsA: Foundation does not work anything using Javascript
It seems you forgot to boot Foundation. Put this just before the </body>, and the dropdown will work: <script>$(document).foundation();</script>…
-
8
votes2
answers5665
viewsA: Check duplicate values in the array
One practical way (but I don’t know how to judge performance) is to filter duplicates to another array, and compare sizes: $array = array(10, 30, 10, 40, 40); $copia = array_unique($array);…
-
4
votes1
answer1331
viewsA: jQuery Ajax does not work on IE8 and IE9
You are trying to use CORS, which is a method to allow access to another domain via Ajax. IE only came to support this in the standard way from version 10, and jQuery does not support CORS for IE8…
-
9
votes7
answers16899
viewsA: How to create a <select> with images in the options?
Cannot place images in the <select> or in <option>s. You will need to create your own selector with HTML and Javascript, or use a ready one such as Select2.…
-
2
votes1
answer220
viewsA: Cakephp Does Not Display Special Characters Present in Database Content
In the bank configuration that is in app/Config/database.php, you need to define the encoding connection. In the case of the Cake for Mysql example configuration, just uncomment the commented line:…
-
5
votes3
answers1771
viewsA: Print html code
Use < instead of <, and > instead of >.
-
4
votes1
answer118
viewsA: Mysql event to block user with x denunciations
You just need to count the results: SELECT COUNT(*) AS denuncias FROM tabela WHERE denunciado = 'userY' Or, if you want the answer already in the query (example for more than 5 complaints): SELECT…
-
6
votes1
answer115
viewsA: My if ever falls on Is
You are using = instead of == (an assignment instead of comparison): if ($("#nome").get(0).volume == 0.1) { $("#nome").prop('muted', true); } else if ($("#nome").get(0).volume == 0.4) {…
-
7
votes3
answers7057
viewsA: System of infinite categories and subcategories/children
With this database structure, you can use a recursive function (a function that calls itself) in PHP to extract as many levels as there are in the database from the tree. The downside of this is…
-
31
votes4
answers17158
viewsA: Include another HTML file in an HTML file
If you’re using a webserver (for example, Apache or IIS), it probably supports Server-side includes. With this you could use, in the main HTML: <!-- #include file="caminho-do-menu.html" -->…
-
1
votes1
answer84
viewsA: SUBSTRING_INDEX with REGEX
The function REGEXP returns 1 if they find anything, and 0 if not find. Therefore in that case you cannot use the comparator =, need to change the query thus: ... WHERE SUBSTRING_INDEX(Usuario.nome,…
-
11
votes3
answers468
viewsA: Include/Require 'file.php' or Include/Require('file.php')
include and require sane statements, not functions. Therefore, parentheses are not necessary. When you include them, the whole part of the parentheses is considered an expression, and that…
-
4
votes3
answers497
viewsA: Take matrix size with EQ() - Jquery
What jQuery returns to $( "body" ).find( "div" ) is a "jQuery object", which is very similar to an array. In many ways, it can be treated as if it were one (for example, it has property length…
-
9
votes2
answers2006
viewsA: Problem with delay in jquery
The method delay only goes for animations, and hide an element without fade, only manipulating the property display, does not involve animation. A brief fadeOut should solve:…
jqueryanswered bfavaretto 64,705 -
1
votes4
answers477
viewsA: Height of one div based on another div
Considering what you said in previous question, You seem to lack the concept of asynchronous operations for you to understand what is occurring. Whenever you make a request by ajax (for example, in…
-
5
votes4
answers5851
viewsA: How to order a Mysql search with date in d-m-Y format?
If the date is stored as text, you can use the function STR_TO_DATE mysql: SELECT data FROM tabela ORDER BY STR_TO_DATE(data, '%d-%m-%Y');…
mysqlanswered bfavaretto 64,705 -
5
votes1
answer1002
viewsA: How to pass variables between PHP pages via Javascript?
Three ways to do this: Pass the filter through Ajax to the server, and save to the session for later use Save the filter to a cookie generated and consumed by Javascript Store the filter in the…
-
3
votes2
answers993
viewsA: Problem with uploading in PHP
By the error description, the problem is that you are passing only the directory as the second parameter to move_uploaded_file. You need to pass a full path including the file name at the…
-
3
votes2
answers2478
viewsA: How to insert multiple arrays into a Mysql table
If the question is to insert multiple rows into the table with a single query, you can use the following syntax: INSERT INTO tbl (col1, col2) VALUES (val1, val2), (val3, val4); The above example is…
-
2
votes4
answers483
viewsA: Is it possible to check the size of a string that is inside an array?
Use empty: if(empty($variavel)) { ... He returns true for both empty strings and empty arrays.…
-
13
votes3
answers26168
viewsA: What is meta charset in HTML?
According to the specification of HTML, the element <meta>, who must at all times be in the <head>, "represents various types of metadata that cannot be represented with the elements…
-
6
votes3
answers462
viewsA: My code does not abort form submission as it should
You have two big problems with your code: To function as you want, you need another return within the onsubmit: onsubmit="return subimitar()" Your Javascript uses a function that does not exist,…
-
19
votes3
answers4757
viewsA: How do I make a Marquee without the <Marquee> tag?
In fact to tag <marquee> is considered obsolete in HTML5, because it is an element focused on behavior and appearance, and not on content structure. Therefore, it is recommended that something…
-
3
votes2
answers94
viewsA: Background disappears when my menu items are horizontal
When you float the elements inside a container, it behaves as if it were empty - so no dimensions, and no background. The solution is to put overflow: hidden in the container to "clean" the floats.…
cssanswered bfavaretto 64,705 -
1
votes3
answers992
viewsA: Return only the newest record of each author
The query you need, in pure SQL, is like this: SELECT membro_id, MAX(data_discurso) FROM tabela GROUP BY membro_id ORDER BY MAX(data_discurso) DESC, membro_id If you need any more fields in the…
-
16
votes3
answers9289
viewsA: How to change the title of each PHP page dynamically?
The ideal would be to have the title stored in a variable at the top of PHP, and use the value of that variable both in <title> how much in the <h1>. For example, the one-page code would…
-
1
votes1
answer259
viewsA: How to pass an SQL expression for an UPDATE to Zend?
From what I saw in a reply in English, to pass an expression like this to Mysql it is necessary to create an object of type Zend_Db_Expr. With that your code would look like this: $db = new…
-
5
votes3
answers5368
viewsA: How to add an onBlur event without overwriting the original?
Solution #1 (recommended): addEventListener With addEventListener you can associate so many Event handlers an element as many as necessary: obj.addEventListener('blur', function() { alert("2"); },…
javascriptanswered bfavaretto 64,705 -
8
votes3
answers2246
viewsA: What is the percentage difference between the number of possible addresses with Ipv4 and Ipv6?
Free translation of Wikipedia content in English: Ipv6 uses 128-bit addresses, allowing 2128 or 3.4 1038 addresses, i.e., more than 7.9 1028 times more than Ipv4. This means, as the comments posted…
-
5
votes1
answer483
viewsA: Scope of variables within $.getJSON
The problem is that getJSON is asynchronous. When the callback executes, the loop has already ended. The scope of its variables is the function that contains them (in this case, the callback…
-
0
votes5
answers6608
viewsA: Capture dates of a text using regular expression in javascript
If the format is always dd/mm/aaaa, regular expression is very simple: \d{2}\/\d{2}\/\d{4} Online test…
-
4
votes1
answer97
viewsA: What does this chunk of PHP code do? My validations fail because of it
Line by line: foreach ($queries as $id => $query) Loop over the array $queries. For each item, the value of the key will be stored in $id, and what is under the key will be stored in $query. if…
-
4
votes1
answer306
viewsA: PDO deletes columns with equal names
According to this reply from the OS in English, you can instruct the PDO to include the table names in the name of each column: $conn->setAttribute(PDO::ATTR_FETCH_TABLE_NAMES, true); With this,…
-
3
votes1
answer879
viewsA: Add and remove percentage
10% of 110 is 11, so the result is correct. To get 100, the question is "what is 110 when you add 10%?": 1.1x = 110 Soon: x = 110 / 1.1 x = 100 Edit: Your Java code looks right. If you are having…