Posts by Oeslei • 5,209 points
127 posts
-
2
votes1
answer94
viewsA: Image cut when decreasing page width
This happens because the class col-11 apply the width through a percentage (relative measure) and you applied the margin in pixels (absolute measure). To correctly center the image in the center of…
-
0
votes2
answers32
viewsA: Javascript Onclick run multiple times
Use css to display the border. So just use the method toggle to add / remove the class responsible for adding the border. In the JS: this.classList.toggle('com-borda'); In the CSS: .com-borda {…
javascriptanswered Oeslei 5,209 -
0
votes1
answer146
viewsA: stylizing a ul that will serve as a select
Your first Istener on .selectOption should be re-viewing the options whenever you click on any option. This happens because the events propagate to the parent elements. To prevent this from…
-
0
votes1
answer372
viewsA: Conflict between a Jquery call and a js file
The argument passed to the callback of the method ready refers to selection, in your case document. That is, you are receiving the variable $ as a reference to document and not to the jQuery.…
-
1
votes0
answers1035
viewsQ: Execute existing function by Selenium-webdriver`executaeScript`method
I am trying to run a function in the browser that is already set, but it is marked as undefined. I ran the following code to reproduce the problem: const webdriver = require("selenium-webdriver")…
-
0
votes3
answers163
viewsA: How can I pass php data to javascript in this case?
You can simply pass as two separate parameters: // função js function criaMapa(latitude, longitude) {} // chamada php echo '<script>criaMapa(' . $cont['latitude'] . ', ' . $cont['longitude'] .…
-
2
votes1
answer280
viewsA: After . load on a div, js no longer works
When you change the contents of the div with content.html(...) you are removing the elements that had the link with your routine through the event click. There are two simple ways to solve this…
-
1
votes6
answers393
viewsA: If it doesn’t work
Consider this part of the code: // ... $data_senha = mysqli_query($conexao, $sql4); if ($hoje >= $data_senha) { // ... The variable $data_senha does not have the value of the date, but an object…
-
0
votes2
answers379
viewsA: Array returning Undefined because of asynchrony
The problem is that its global variable x is being overwritten before being used again in the return of the API to retrieve the cards. The simplest solution would be to pass the variable x.name as a…
-
1
votes3
answers672
viewsA: What is the advantage of using Function(window, Document, Undefined)
I know the question is old, but since you linked the same one in an answer, it is worth adding some details. it is useful to pass objects this way to perform tests. when developing into Node, the…
-
3
votes2
answers157
viewsA: Why copy the prototype method instead of using directly?
Javascript arrays are erroneously used by some as associative arrays, which are nothing more than objects. // versao correta var arrAssociativo = {}; arrAssociativo.minha_chave = 'meu_valor'; //…
-
1
votes1
answer362
viewsA: Structure for PHP project and use of the Eval() function
Why don’t you use classes? For example: interface Regras { public function execute(); } class RegrasApp implements Regras { public function execute() { // suas regras aqui } } $regras = new…
-
3
votes3
answers381
viewsQ: Chrome [v44] - Bug in tables inside a div with overflow
In the new version of Chrome (version 44) the tables are not behaving in the same way as the other versions of it behaved. Expected: Upshot: When resizing the screen, the browser calculates the…
-
7
votes3
answers1766
viewsA: Ajax cross Domain
If the site in question has access both by http how much for https just remove the protocol from the request that the browser will use the current protocol. This technique is widely used to load…
-
0
votes2
answers474
viewsA: Incomplete week name on strftime return
With dates to always several possible solutions. Here are some: $diasSemana = array('domingo', 'segunda-feira', 'terça-feira', ...); echo $diasSemana[strftime('%w', strtotime('now')]; $now =…
-
1
votes2
answers475
viewsA: How to avoid error when variable not declared
The simplest way to check whether the variable has been defined takes into account that js considers the value undefined as false in one condition. However the values null and 0 are also considered…
javascriptanswered Oeslei 5,209 -
0
votes5
answers364
viewsA: Hierarchy between CSS styles
I was studying jquery mobile code to check how themes were processed. What happens with jquery mobile is that the theme is set via an attribute data-theme and at application startup all html is…
-
4
votes5
answers364
viewsQ: Hierarchy between CSS styles
I’m studying some more efficient ways to style an app using themes. My idea would be to use something like this: <div class='tema-1'> <button class='btn btn-primary'>botão…
-
1
votes1
answer1053
viewsA: Line-Height - Leaves No Vertically Centered Text
The line-height does not serve to align the text vertically, who does it is the vertical-align (in your case, you want to vertical-align: middle;). However, the line-height is necessary because the…
-
0
votes3
answers166
viewsA: How do I make an Alert?
You can use the function confirm which is native to browsers. It returns true or false according to the user’s response. if (confirm('Deseja ir para a página de configurações?')) {…
-
4
votes2
answers8263
viewsA: Assign Mysql query result to a PHP variable
Add the query an alias to the desired column. For example: $sql = mysql_query("SELECT COUNT(*) as total_registros FROM `users`"); Then, just select the alias you used: $total =…
-
1
votes2
answers3779
viewsA: How to show an image every 5 seconds javascript
You can use the setTimeout to generate the desired delay. function iniciarSlideImagens() { var exibirImagens = function(current) { var arrImgsAmarelas = [ 'amarelo0.png', 'amarelo1.png' ]; var…
javascriptanswered Oeslei 5,209 -
2
votes3
answers276
viewsA: Why does it always return null?
Complementing @Sergio’s reply, you don’t need to select by id because when you pass a string with html to jquery, as you are using it, it keeps all the elements as a selection root (in case, just…
-
5
votes5
answers20983
viewsA: Grab content from another page by javascript or jquery
To make a request between domains, as you are doing in the example, you need to set the header Access-Control-Allow-Origin on the requested page. Since you are using the Google site as an example,…
-
2
votes3
answers433
viewsA: Sending external PHP variable to Javascript
A simpler way: perform the checks directly in php and pass the result to js. <?php if ($_SESSION['VALIDACAO'] == 01) { $texto = "Login inválido"; } else { $texto = "Úsuario bloqueado, contacte o…
-
3
votes2
answers1027
viewsA: Place an HTML tag on the </body> using string (PHP)
Use the function str_replace which is used to replace one part of the text with another in a string. For example, in your case: $textoAdicional = '<table>...</table>'; $texto =…
-
2
votes3
answers4208
viewsA: Is it possible to create an object dynamically in JS without using Eval?
It’s very simple. An object in javascript can be used as an array, i.e.: var arr = ["meu", "objeto", "dinamico"]; var val = 100; var obj = {}; var currentObj = obj; var lastIndex = arr.length - 1;…
-
1
votes6
answers4694
viewsA: How to make a stopwatch continue counting after closing the page?
If you don’t need to worry about the user changing their variables in js I advise you to follow the @Lucaspolo solution, otherwise do something like this: When starting the timer, js executes a…
-
3
votes2
answers2260
viewsA: Settings for javascript Alert
The alert just displays the given string, without formatting anything. What happens is that javascript itself interprets some special characters in a string. The most common are \n (line breaking)…
javascriptanswered Oeslei 5,209 -
5
votes2
answers10413
viewsA: Button spacing
You cannot remove the space because the browser places a space character between the buttons (due to a space, line break or indentation in the code itself). Here are two possible and…
-
5
votes5
answers1659
viewsQ: Default parameters
I’m having a problem with the parameters in a PHP function. For example: function exemplo($par1 = 1, $par2 = 2) { return $par1 . " - " . $par2; } exemplo(); // 1 - 2 exemplo(3); // 3 - 2 exemplo(3,…
-
7
votes2
answers1163
viewsQ: Detect if the event was triggered by the user or via script
I need to detect if the event (click) was triggered by the user or method trigger jQuery. Analyzing the parameter event found two properties I could use for this check: when the event is triggered…
-
4
votes1
answer277
viewsA: While - Returns only one record
The problem is that you are already using the function mysql_fetch_array before the repeat loop, that is, you have already obtained a record, and the while will start in the second. A simple…
-
4
votes2
answers2522
viewsA: addeventlistener does not work with passing parameters
When you pass a callback function as parameter it is impossible to pass parameters directly, because when you add the parentheses, js executes the function, i.e., you are passing the function result…
javascriptanswered Oeslei 5,209 -
5
votes2
answers521
viewsA: How to make race effect?
You can use the styles transform and transition. The first can be used to move (easily and more browser friendly) elements on the screen. The second serves to declare that you want to animate…
-
0
votes4
answers1160
viewsA: load datepicker plugin on page called with ajax
To start, the settings you can set using the function setDefaults. $.datepicker.setDefaults({ dateFormat: 'dd/mm/yy' }); Now, to add datepicker only to class inputs datepicker and which do not yet…
-
3
votes1
answer45
viewsQ: Functions with public property
How is it possible to use a function as an object? More precisely, I would like to repeat the behavior of $http angular, where it is possible to execute a request in the following forms:…
-
12
votes2
answers151
viewsQ: Name for anonymous functions
In some example code frameworks, libs, etc. I found that anonymous functions were passed with a name to the same. minhaFuncao(function minhaFuncaoAnonima() { // ... }); What is the purpose of naming…
-
4
votes2
answers1288
viewsQ: replace using regular expressions
I am running a replace with regular expressions to format a string, such as CPF: var cpf = '99999999999'; cpfFormatado = cpf.replace(/(\d{3})(\d{3})(\d{3})(\d{2})/, '$1.$2.$3-$+');…
-
1
votes2
answers2913
viewsA: Change value of a variable with PHP button
This is not possible. php runs on the server and after running, everything is on account of the client (browser). When the browser requests the server, php is executed and returns the result (html)…
-
0
votes1
answer145
viewsA: When browsing page receives unexpected value of $_SESSION
To better understand what’s going on, you need to understand how the sessions work in php. In short, when a user accesses your site, they gain a unique identifier (the session id) that is saved in a…
-
0
votes3
answers65
viewsA: Increment or decrease var in resize window
You just have to decrement 1000 of the window value whenever you set the variable. For example: var tamanhoJanela = getTamanhoJanela() - 1000; // 1000 - 1000 = 0 // 997 - 1000 = -3 // 1003 - 1000 =…
javascriptanswered Oeslei 5,209 -
7
votes2
answers781
viewsA: Delete all console logs
The command to clear the console is console.clear(). If you are not cleaning the console, you should have the option Preserve log enabled. This option serves to prevent other scripts from clearing…
javascriptanswered Oeslei 5,209 -
4
votes3
answers11265
viewsA: Sessions in JS or jQuery
There are several ways to keep information on JS: Cookies: the oldest and most common form. Easy to set a variable, but requires a little extra code to get or remove. It has space limit and is sent…
-
1
votes1
answer900
viewsA: Using a variable created within an AJAX request in another function
I believe that the total height should be obtained only where necessary or even in another function, because it does not seem to be one of the functionalities of the function pega_imagens. From what…
-
1
votes1
answer122
viewsA: WEBSOCKET and PHP data storage
Depending on the amount of information, using Sesssions may not be the best idea. If you want an alternative, you can save it to the database with the current session id as a reference (session_id)…
-
2
votes1
answer114
viewsA: Regular expression search
You cannot create a regular expression literally by passing a variable as js will not interpret the variable. What you can do is create an object RegExp: return new RegExp(rst.dst, 'm').test(tel);…
-
2
votes4
answers174
viewsA: Is it possible to use PHP in a data-title field?
php works anywhere in the file. How you reported the problem citing only the attribute data-title I believe the other attributes (data-date-created, ...) are working. If so, I believe your variable…
-
4
votes3
answers632
viewsA: Replacement for TAG <center>
The style text-align: center; center the content within a block. In your case you didn’t center because you put the wrong style: text=align:center; where it should be text-align: center;. To center…
-
3
votes2
answers841
viewsA: How to add a field of a given ID with multiple records?
You can use the SUM. For this, you will need to group the records: SELECT SUM(tot_votos) as total_votos FROM ... GROUP BY id_candidato To get the candidate’s information in the same survey, you will…