Posts by Lucas de Carvalho • 6,427 points
260 posts
-
0
votes3
answers91
viewsQ: Variables are automatically executed when declared?
For example, if we keep one setInterval() in a variable, it already runs automatically even without that variable being called anywhere? Example: let i = 0; let myInterval = setInterval(function(){…
javascriptasked Lucas de Carvalho 6,427 -
2
votes1
answer117
viewsQ: Cut image pixels without distorting it
Good morning! I want to cut the sides of a photo without distorting it, it’s possible? For example, I have this image here: <img src="https://i.stack.imgur.com/4oeoT.jpg" name="Foto Teste"…
-
6
votes2
answers99
viewsQ: How does the mini-code finder work?
I am asking this because I was minificar a JS and he gave me a code that I did not understand very well... My original code: $('input').each(function(a,b){if(b.value ==…
-
0
votes3
answers7056
viewsA: Change background-color when click
You can do so by just adding a buttonClicked class with javascript (removing before all others) let myButton = document.querySelectorAll('.button-group > button'); myButton.forEach(function(key){…
-
0
votes1
answer179
viewsQ: What does PDO Prepare do when we use it?
What exactly prepares it does? For example, does it encrypt, or something like that? Because, to be honest, I use the method, but I never really understood its use. <html>…
-
0
votes2
answers1437
viewsA: Autoload Composer class not found
My question was answered by the user @Jorge Costa no chat! Lucas Gauna also gave practically the same explanation. swap the namespace Conec (Class Conn) to the folder name in issue (CONN) Thank you…
-
0
votes2
answers1437
viewsQ: Autoload Composer class not found
Good afternoon! I have a problem and do not know how to solve, creating a mini application, using the autoload of Composer, but is not working, is giving that class does not exist. This is my…
-
5
votes2
answers7405
viewsQ: What is the difference between SCHEMA and DATABASE?
I had never used Mysql Workbench and it instead of database, gives me the option of SCHEMA. What is the difference between the two? It gives in the same one or the other?
-
3
votes2
answers53
viewsA: Limit the number of uses of a function
I’ll create an example: let qtdVezes = 0; function usarFunc () { if(qtdVezes >= 5){ alert('Você não pode mais usar essa função!'); return false; } qtdVezes++; console.log('Você está usando a…
javascriptanswered Lucas de Carvalho 6,427 -
0
votes2
answers56
viewsA: Random site background videos
You could save the urls of the videos in a database, and use the Math.() to make the exchange of Urls An example using array (as a database): let urls = [ 'http://meuvideo.com/1',…
-
0
votes1
answer237
viewsQ: What is bit-a-bit operation?
I’ve read some things here at Stack Overflow, but I don’t quite understand. What is bit-to-bit operation? For example, in the context: Considering bit-to-bit operation 15 3, the result will be:…
bitasked Lucas de Carvalho 6,427 -
5
votes3
answers129
viewsQ: Why are Javascript objects not always JSON?
For example: { "nome": "Meu nome", "sobrenome": "Meu sobrenome" } Can it be considered an Object and also a Json? If not, why not? What will differentiate one from the other is when instantiating?…
-
0
votes2
answers71
viewsA: Doubt HTML attribute sum
I didn’t quite understand it, but that would be it? function myNewUrl(url, action, val){ return url +'?' + action + '=' + val; } document.querySelector('.my_form').addEventListener('submit',…
-
1
votes1
answer58
viewsQ: Use return prompt with ternary operator
How can I use its return directly in the expressions? Because I can only use it if I open the prompt 2 times. I wanted, if in condition, the value is what I want, it (the value) fall in the direct…
javascriptasked Lucas de Carvalho 6,427 -
2
votes2
answers55
viewsA: Custom border for certain table columns
With CSS3 you can do this by using Nth-Child Example: td { border-right: 2px solid red; padding: 20px; } td:nth-child(odd){ border-right: 2px solid blue; } <table> <tr>…
-
0
votes4
answers67
viewsQ: Create a role or use the code directly?
What is most recommended? In a situation I can use both modes (I can choose, it will work the same way). What is recommended to do? Create a role or insert the script directly into the JS file?…
javascriptasked Lucas de Carvalho 6,427 -
0
votes1
answer137
viewsA: Redirect if basket is empty | Woocommerce 3+
Every (or almost every) empty cart in wordpress has the p tag with the class cart_empty, so with a simple Javascript you can check the length and if it is greater than 0, it is because the cart is…
-
2
votes4
answers19922
viewsA: Limit the number of SQL query lines
Use the LIMIT SELECT estado, num_ocorrencia FROM bra_ocorrencias WHERE nome like 'João' ORDER BY num_ocorrencia DESC LIMIT num_limit Read more here!…
-
0
votes1
answer38
viewsA: Sending a PHP form
You can do it with Javascript and get value: function getFormSubmitValues(formId){ document.getElementById(formId).addEventListener('submit', function(e){ e.preventDefault(); const queryMyInput =…
phpanswered Lucas de Carvalho 6,427 -
2
votes1
answer904
viewsA: How to validate an HTML form with Javascript?
The required will already do this for you, will not let you submit without filling in the input, but with JS you can check if the value is empty: function ValidarFormulario(id){ const idForm =…
-
0
votes2
answers490
viewsQ: Callbacks in Javascript
I’d like to understand something about callbacks! I know there are other topics on the subject, but mine is a simple question and is not clear to me yet. For example, let’s assume I have this array:…
-
4
votes2
answers154
viewsA: How to align items with HTML and CSS?
I replicated your example using Flexbox #contato { margin-top: 120px; } #contato form { width: 100% display: flex; } .input-flex { display: flex; } .input-flex > input { width: 33%; } #contato…
-
1
votes3
answers946
viewsA: Function to add Multidimensional array elements
You want to create an array that serves as "database"? But other than that question, you, with a function, which is what you want, can do exactly like this: <?php //Array $data = array(…
phpanswered Lucas de Carvalho 6,427 -
6
votes2
answers2025
viewsA: What is the maximum and minimum value for z-index?
Information taken from the Internet: │ Browser │ Max z─index value │ When exceeded, value changes to: │ ╞══════════════════════╪═══════════════════╪══════════════════════════════════╡ │ Firefox 0 -…
cssanswered Lucas de Carvalho 6,427 -
1
votes2
answers361
viewsA: Problems with jquery and input mask
Since the input is text type, and has commas, what the input is returning is a string, and for that, you will have to format the value of it turning into a number: function formatVal(val){ let valor…
-
2
votes2
answers56
viewsQ: Ignore first input reading
How do I ignore reading the first value of an array? I don’t want to remove it, I just want it to be displayed, it doesn’t appear the same: I’ve done it before: document.querySelectorAll('.form…
javascriptasked Lucas de Carvalho 6,427 -
2
votes1
answer49
viewsQ: "Arguments" doesn’t work on an Arrow Function?
I’m doing a simple test with Arrow Function, but when I use the arguments he returns Uncaught Referenceerror: Arguments is not defined How can I use the parameters? const teste = () => { for(i in…
-
0
votes1
answer56
viewsQ: Explanation Hoisting Javascript
In Javascript, every variable that is declared with the keyword var is "high" (Hoisting) to the top of the execution context, right? function testandoMsg (){ let b = 'B'; console.log(a);…
-
0
votes1
answer27
viewsQ: Do individual requests influence website speed in general?
Good morning! A customer is on the site, it runs on the console a code like this for example: setInterval(function(){ console.log('Teste'); }, 1); This code of his, running in his browser, can it in…
-
1
votes3
answers81
viewsA: Hide text between javascript keys
Hello, try that regular expression: let getDiv = document.querySelector('.teste').innerHTML; let newTeste = getDiv.replace(/(\s\{.*?\})/, ''); document.querySelector('.teste').innerHTML = newTeste;…
-
0
votes0
answers89
viewsQ: Does letting active setInterval slow down the site?
For example, I have a setInterval that will stay 1 in 1 second checking if the company chat is with any online attendant. If any attendant goes online, I give a clearInterval and stop the function,…
-
2
votes1
answer110
viewsQ: JS of a document working within iframe html
Good afternoon, you guys! I have my site for example, which has the normal page that every page has, html, head, body, etc... Inside this my page, has an iframe, this iframe pulls another html from…
-
0
votes4
answers382
viewsA: How to call function in JS only once
Dude, you set a setInterval of 1 in 1 second, it will always go to the end of the chat. Only thing you need to do for it to run once only when opening the page, is to take the setInterval and…
-
0
votes3
answers396
viewsA: Odd Number Calculation - Javascript
Dude, if dividing 100 to 3 is going to be 33.33, rounding it down, it would be 33% each. It’s impossible to always give 100, it doesn’t make sense. To round down you can use the Math.floor() let a =…
javascriptanswered Lucas de Carvalho 6,427 -
0
votes1
answer34
viewsQ: Difference in Javascript attribute creation
What is the real difference between creating these two ways? function Pessoa() { this.nome = 'lucas' } and function Pessoa() { nome = 'lucas' } When it comes to instantiating, there will be some…
-
0
votes1
answer535
viewsQ: Onclick Javascript event
I’m testing the Onclick on JS and I’m weirding a deal, it works only when I glue the console document.querySelector('.a').onclick = teste2(); , or the first time I run/open the page. If I click on…
-
3
votes1
answer37
viewsA: Problem to find the IP
No error, it is returning the value of Ipv6: "The localhost name usually resolves to Ipv4 loopback address 127.0.0.1 , and to Ipv6 return address :: 1." Try to configure Apache correctly.…
phpanswered Lucas de Carvalho 6,427 -
2
votes1
answer142
viewsQ: Do the parameters passed in the * selector (asterisk) override anything in the CSS?
Testing here, I saw that if I use a background-color in the * selector (asterisk), all the elements will have that background, further on, if I want to put a different backgroud-color, in a div for…
cssasked Lucas de Carvalho 6,427 -
0
votes2
answers847
viewsA: PHP timer function
You called the function inside the function, and when you do that, you’re going to keep giving it an infinite loop, you know? Because she will run the same all over again, and will end up running…
phpanswered Lucas de Carvalho 6,427 -
0
votes1
answer46
viewsQ: Difference of Character and charset
I’m picking up a few things in SQL, and sometimes I come across CHARSET and CHARACTER For example: create database teste default character set utf8; And now, creating a table: create table teste (…
-
3
votes1
answer595
viewsQ: Differences in Phpmailer functions
In the documentation it does not leave much explained that (think), so what would be the difference of: I’m using the variable $mail for example. $mail->Username $mail->setFrom…
-
0
votes2
answers1007
viewsA: Create php folder inside another folder
Put an Else in ! file_exists, so that if it exists, it creates a new one instead of updating the old one. For example: if(!file_exists($strCaminho)) { $objProjetoDiretorio =…
-
0
votes1
answer330
viewsQ: Unexpected token in import
Is giving the following error of syntax in the plugin typed.js: Uncaught SyntaxError: Unexpected token { Along those lines: import { initializer } from './initializer.js'; import { htmlParser } from…
javascriptasked Lucas de Carvalho 6,427 -
1
votes1
answer122
viewsA: Magic Constants Returning Null or Halfway
Give a var_dump on __DIR__ . DIRECTORY_SEPARATOR . 'arquivo.php' and see what he returns. If you copy the link that returned and that link, in the URL bar returns some file, the problem is another.…
-
1
votes2
answers65
viewsQ: What is Javascript Graphics?
I have a plugin, that gives me tools that that site uses, in one of them, it appears this: Grafismo Javascript what would that be in case?…
javascriptasked Lucas de Carvalho 6,427 -
0
votes0
answers52
viewsQ: Timthumb-friendly URL
Today, I use this rule to create friendly URL and use MVC in my projects: RewRiteRule ^(.*)$ /index.php?url=$1 [QSA,L] In this case, I use Timthumb to generate cached images in PHP, and it returns…
-
1
votes1
answer52
viewsQ: Run Javascript within meta tag parameter
Is there any way to do what I said in the title? I tried it this way but it seems to me that it does not perform the function: <script> function imgPrincProdu(){ return $('.flickity-slider…
-
9
votes2
answers1709
viewsQ: There is an "Else while"
Is there any way I can do that? As long as it’s one thing to do that, then when it’s another to do that? For example: var i = 0; while(i < 5){ //faça isso i++; } else { //faça aquilo } It’s…
-
0
votes3
answers701
viewsA: (Laravel) How to ignore null values in $request->all()?
You can use in_array maybe, I don’t know Windows, but I think it should work. $minhaArray = array("Nome" => "Lucas", "id" => "1", "Idade" => null); if(in_array(null, $minhaArray)){…
-
5
votes2
answers419
viewsQ: Is it possible to instantiate a class without storing it in a variable?
Normally I do so: $a = new MinhaClass($Parametro); You can do this without creating the variable $a ? Only with the new?