Posts by bfavaretto • 64,705 points
902 posts
-
5
votes1
answer1120
viewsA: Retrieve data from fields of the same name but from different tables
Use a alias in each of these fields, which you define with AS: SELECT suporte_cad.reg, suporte_cad.data, suporte_cad.status, suporte_cad.nmcontato, suporte_cad.mensagem AS mensagem_cad,…
-
4
votes2
answers151
viewsA: Include class as link
Split: When the user hovers the mouse over the li that has the a/engineering (...) $('li').mouseover(function() { var li = $(this); if(li.contains("a[href='/engenharia']")) { // SUA LÓGICA AQUI }…
jqueryanswered bfavaretto 64,705 -
3
votes1
answer905
viewsA: Get mouse coordinates for a specific element
At the event mousemove of a given element, you get the cursor coordinates in relation to the window with the properties clientX and clientY of the event: elemento.onmousemove = function(e) { //…
javascriptanswered bfavaretto 64,705 -
4
votes1
answer74
viewsA: How to make a cursor to overlay a graph?
Maybe this is what you seek: two lines forming a cross, accompanying the mouse position: var v = document.querySelector('.cursor-v'); var h = document.querySelector('.cursor-h'); var elBox =…
javascriptanswered bfavaretto 64,705 -
1
votes1
answer218
viewsA: Filter through multidimensional objects with underscore.js
If I understood well what you pasted (it looks like a console output), and considering that you have an array of objects, it would be like this: var filtrado = _.filter(data, function(obj){ return…
-
7
votes1
answer48
viewsA: How to find the second id of something
This is not possible *because Ids must be unique. If you need to identify more than one element with a name, use classes instead of Ids: <div class="general">ds</div> <div…
-
3
votes2
answers45
viewsA: Assign ownership of five out of five elements
Considering your editing: in IE8 there is no solution in pure CSS. You will have to cast the number of list items in your rules, or use Javascript. Below, CSS solution for modern browsers. For this…
cssanswered bfavaretto 64,705 -
3
votes2
answers203
viewsA: App novice. Where to start?
If you’re going to develop with Phonegap, you can use any maps API that works on the web, such as Google Maps, Bing Maps and Openstreetmap. To get the current position of the device that is using…
-
2
votes1
answer266
viewsA: Script instability to hide/show fields
The error is on this line: if ($("#dn").attr("checked",true)) { The $("#dn").attr("checked",true) marks the checkbox as checked, and still returns an object, which will make the execution always…
-
11
votes4
answers714
viewsA: Trying to condense conditional with three possibilities
Parentheses left on the nested probation: $html = ($ni > 1) ? ' ('.$ni.' itens)' : (($ni==1) ? ' (1 item)' : ' (nenhum)'); // ^ ^ Without it, the PHP prioritizes the first sequence of ?: who…
-
2
votes2
answers91
viewsA: Refine article ranking based on views of all articles
If I understand the code correctly, this method should generate a very low value for each product, since none will have 100% of the views you pass in $grandTotal. An alternative way to calculate…
-
3
votes1
answer190
viewsA: Error: Expected a conditional Expression and Instead saw an assignment
It is not possible to evaluate if your code is correct or not only by this excerpt, but what you are seeing is an error presented by a tool linting, probably the Jslint or the Jshint. It is not a…
javascriptanswered bfavaretto 64,705 -
3
votes2
answers1305
viewsA: Check that all values in one array are part of another
If I understand the question correctly, and if you really have equal arrays at both ends, you can use the operator ==. He will return true when both arrays have the same keys and values: array('a'…
phpanswered bfavaretto 64,705 -
10
votes1
answer2947
viewsA: How to get the position of a given element in a list through a specific attr?
In the jQuery, index() returns the position of the element within the parent element, counting from zero. If you already have the <li> as a jQuery object, just ask the index his: var posicao =…
-
9
votes2
answers1305
viewsA: Customize javascript object comparison
Although in Javascript it is not possible to overload operators, it is possible to treat how your object will behave in the use of comparators >, >=, < and <=. Just you implement the…
-
4
votes1
answer427
viewsA: JSON return in an array in the LOOP
Use the loop to mount the variable, and only then initialize the autocomplete: var availableTags = []; for (var i=0;i<data.length;i+=2){ availableTags.push({label:data[i+1],…
-
7
votes2
answers245
viewsA: Confused about the correct form of Inheritance in Javascript
Like said Renan, there is no "correct" way, and this solution works well in your example. But I would like to show another that solves a common problem of your solution. The problem occurs when the…
-
4
votes1
answer114
viewsA: Restrict a character limit array in the LIKE
You can restrict the value you use to the left of the LIKE: WHERE LEFT(Endereco, 10) LIKE ...
-
2
votes2
answers251
viewsA: jQuery adding several lines in html
Instead of complementing the content of the div with prepend (or append), define the whole content with .html(): $("#divPrincipal").html('<p class="text-success">Você terá aproximadamente ' +…
-
4
votes3
answers21897
viewsA: Add to html code via jQuery
The problem with this section of append is a syntax error because of the nested double quotes. This: "<p class="text-success">Teste</p>" It is interpreted as two strings with…
-
36
votes4
answers58476
viewsA: IF, ELSE IF, ELSE or IF IF IF. When to use, what’s the difference?
In your example, it doesn’t really matter, for two reasons: There are no two conditions that can be met at the same time. You always return when you enter one of if, and the following do not Now…
-
15
votes2
answers1120
viewsA: What is the use and when to use version in . js and . css files?
This is done to prevent the browser from using a cached version of the file. If your site calls the same JS or CSS on multiple pages, the browser downloads those files from the server only once, and…
-
2
votes1
answer134
viewsA: Implicit type conversion error
The error cites line 47 of the file. I believe this is: txtTitular.Text = this.conta.Titular; If this.conta.Titular is a Cliente, you cannot directly assign to the value of a text field, which must…
-
3
votes1
answer365
viewsA: How to make a query to return the value of another table?
I believe it would be better to get all the information at once, in the same query. You do this with a JOIN: SELECT Produtos.id, Produtos.nomedoprotudo, Produtos.categoriadoproduto,…
-
7
votes1
answer1641
viewsA: How to Save Colors in Database
The structure of its database foresees a relationship between two tables: the colors are recorded in a table (if I understand correctly, the value of the color in hexadecimal), while the clothes…
-
26
votes2
answers3691
viewsA: What is DOM, Render Tree and Node?
HTML <div> <p>Um parágrafo em cima.</p> <p>Outro <span>embaixo</span>.</p> <p>E mais um</p> </div> GIFT div -- p -- p -- span -- p DOM…
-
5
votes2
answers1434
viewsA: PHP imagecopyresampled() function cutting in the wrong place
I think my comments above did not proceed, Jcrop already automatically handles the scale, according to documentation. I removed the comments (and soon remove this notice as well). I think you’re…
phpanswered bfavaretto 64,705 -
11
votes4
answers10036
viewsA: Apply color to font in element clicked only with CSS
With div I don’t know if it’s possible, but with an anchor you can use the pseudo-class :target, thus: .trabalheSubEsqTitulo:visited { color: blue; } .trabalheSubEsqTitulo:target { color: red; }…
cssanswered bfavaretto 64,705 -
11
votes4
answers1592
viewsA: How to ask the PDO if the insertion was made or error?
The execute returns false if the operation fails. You can also get additional information about the error with the errorInfo: $Produtos = $pdo->prepare("INSERT INTO tbl_produtos VALUES (NULL,…
-
3
votes1
answer89
viewsA: How to fix insert error in table genres?
First, we can simplify your handling of the input. It is always recommended to clear the input to prevent injections: $generoMinusculo = strtolower(trim($_POST["genero"])); if ($generoMinusculo) {…
-
6
votes1
answer1018
viewsA: Assigning a key and a value to an object
Two ways to do this: // 1: cast para object $obj = (object) array(); $obj->foo = 10; var_dump($obj); // 2: instância de stdClass $o = new stdClass(); $o->foo = 'bar'; var_dump($o);…
-
5
votes2
answers2005
viewsA: Detect which link was clicked
As mentioned above, you are using a property that only exists in IE (Event.srcElement), but is testing in Firefox. It’s simple to solve this, and I take advantage to leave your code more…
-
13
votes4
answers80887
viewsA: How to force the opening of a link in another tab and not window?
Your HTML and Javascript are redundant. The target="_blank" in HTML already forces the opening of the link in a new window, so JS, which does the same thing, is unnecessary. You could simply use…
-
2
votes3
answers319
viewsA: Search for information by content and not by array position
Your result comes "No" because in the next step the answer is no. Once you find the result, you need to exit the loop: <% mystring = "Como eu faço para separar uma string em várias strings?"…
-
5
votes5
answers758
viewsA: How to embed CSS in HTML tags?
Some email programs do well with declared CSS in HTML itself: <html> <head> <style type="text/css"> .texto { color: red; } </style> </head> <body> <span…
-
7
votes1
answer479
viewsA: Private Property / Protected JS / jQuery
The simplest way is to use a function to generate the object. All values that should be private would be visible variables only in the scope of this function. The getter and the Setter would be…
-
5
votes2
answers81
viewsA: Reorder HTML structure via jQuery
The append inserts an item into final of the selected element, and should work as I see in your example. Maybe your script is adding more items to this container, and you need to put them at the…
-
7
votes1
answer61
viewsQ: What is the difference between $('id') and $('#id') in Mootools?
For those who, like me, are used to jQuery, the existence of two functions to select elements in Mootools seems a little confusing. Whereas I have some element like <div…
mootoolsasked bfavaretto 64,705 -
4
votes3
answers1590
viewsA: How to change URL objects via Javascript?
I’m not sure that’s what you’re looking for, but this fragment that starts with # is called hash and can be obtained and amended accordingly: // pega o valor atual var hashAtual =…
javascriptanswered bfavaretto 64,705 -
10
votes1
answer1037
viewsA: Consult ID in database ignoring scores
You can use the function REPLACE Mysql to replace dots and dashes with nothing: SELECT ... FROM tabela WHERE REPLACE(REPLACE(coluna, '.', ''), '-', '') = '123456789' Important: according to…
-
8
votes1
answer34
viewsA: Doubt with Revealing Pattern
You need to assign the value to the variable before returning. Due to the Hoisting of variables and functions (which I explain in more detail in this other answer), the variable declaration is…
javascriptanswered bfavaretto 64,705 -
8
votes2
answers390
viewsA: Can Missing semicolons in CSS and Javascript influence how code works?
CSS In the case of CSS, I see no problem in removing the ; of the last property of a rule. As after it comes the lock key, there can be no problems. The mini-scanner probably does this to reduce the…
-
43
votes2
answers40509
viewsA: When to use Absolute or relative position in CSS?
This confuses a lot of people because the property position defines two things: how the element behaves in relation to its ancestors in the hierarchy, and how its descendants may behave in relation…
-
12
votes1
answer9080
viewsA: Moving and removing HTML elements with jQuery
I suggest a different approach: instead of creating a new div to insert into the #menuAprendido, find the already existing item in the other menu and move from one place to another. So no need for…
jqueryanswered bfavaretto 64,705 -
7
votes2
answers273
viewsA: How to return different answers with different values in equal Classes?
If you have multiple elements with these classes, you need to loop the set and change them one by one. You can do this with jQuery using the .each(): jQuery(document).ready(function($){…
-
5
votes5
answers910
viewsA: Operator "||" in Javascript variables
This is used to assign standard values to variables. There are 3 contributing factors to this: Javascript expressions always return a value. So nome || "estranho", being an expression, returns…
javascriptanswered bfavaretto 64,705 -
2
votes1
answer129
viewsA: How to use top in image style with relative width?
The problem is that everything has absolute position. In this case, the height of the images does not influence the height of the external div. So the external div has zero height, and any…
-
2
votes1
answer211
viewsA: How to select the result of a CEP json in an existing option?
If you have no way to change what comes in JSON to hit with your values, you need a selector that looks at the content of options, not its value: $("#estado option:contains('" + json.uf +…
-
5
votes1
answer5408
viewsQ: Mysql Error 1153: Got a Packet Bigger than 'max_allowed_packet' bytes
When trying to import a database from a dump with 1.2GB, the following error occurred: ERROR 1153 (08S01) at line 727: Got a Packet Bigger than 'max_allowed_packet' bytes The command I am using for…
mysqlasked bfavaretto 64,705 -
7
votes1
answer5408
viewsA: Mysql Error 1153: Got a Packet Bigger than 'max_allowed_packet' bytes
I found the answer in Michael Pryor’s answer on Stack Overflow. According to him, it is necessary to change a Mysql configuration, and pass an extra parameter to the client on the command line,…
mysqlanswered bfavaretto 64,705