Posts by Oeslei • 5,209 points
127 posts
-
3
votes1
answer4734
viewsA: Pick variable on another page
You can use the session's from PHP. It is very easy to use and only needs to be started at the beginning of the script and then access through the global variable $_SESSION. On the page that…
-
18
votes2
answers2027
viewsQ: What are operators for | & << >>?
I was analyzing a code and found some operators I don’t know: |, &, >> and <<. What is the functionality of these operators? bits = h1 << 18 | h2 << 12 | h3 << 6 |…
-
1
votes6
answers1754
viewsA: Hide dives after selecting another category
You could create an array to indicate which div should be displayed. It would also be a good idea to add a div'desired to be able to hide without further difficulties. <div id="x"…
-
3
votes2
answers4875
viewsA: Create Editable Table
1. You can resolve using classes in columns and id’s in rows to identify them. For example: <tr id="linha1"> <td class="numero">123</td> <td class="nome">Teste</td>…
-
7
votes2
answers4065
viewsA: Forward tab by clicking the button
The simplest way I see is to trigger the event click in the tab. Just add a trigger("click") in the row enabling it: $('button').click(function(){ /*enable next tab*/ $('.nav…
-
3
votes3
answers828
viewsA: How do I generate a hash in the client-side?
You can use the bcryptjs. var bcrypt = dcodeIO.bcrypt; var hash = bcrypt.hashSync('password', 12); It is worth performing some performance tests to verify that a cost of 12 will not be too slow for…
-
4
votes1
answer108
viewsA: Dawn greater than night
01:00:00 is not greater than 23:00:00. However, to identify if 21/02/2015 01:00:00 is greater than 20/02/2015 23:00:00 you can compare the timestamp. For example: // mktime(hora, minuto, segundo,…
-
9
votes2
answers558
viewsA: What is the difference between $(this) and $(Event.target)?
The this refers to the element to which the event was attached. Already the event.target refers to the element that triggered the event. For example, suppose you’re manipulating a table and want to…
-
2
votes1
answer753
viewsA: Ajax does not work on Firefox
The problem is not that the request is not working, it is the way you are trying to redirect the user. Chrome is probably the only one that considers metatag that you are using after page loading.…
-
2
votes1
answer54
viewsA: How to pass a Jquery plugin as a parameter for the On event
You can pass a function that calls the $.confirm. For example: $("#elemento").on("click", function() { $.confirm(); });
-
2
votes3
answers225
viewsA: E-mail being sent in duplicate to each contact
The problem is you’re giving a send whenever you add an email to the mailing list. You could modify your code to look like this: do { $id = $row_News['id']; $email = $row_News['email']; $nome =…
-
8
votes2
answers154
viewsA: Return a function
The problem is not that its function does not run. It just does nothing but mount the table string and end of the story. You need to return the string in order to receive the value. function teste()…
-
2
votes2
answers1022
viewsA: How to get the return of an instantiated Function (new + Return) - Javascript
As @bfavaretto said, this is not possible. What you can do is create a method to return the value and chain it with the constructor. For example: function Teste() { this.valor = 'valor no this';…
-
1
votes2
answers1490
viewsA: How to clear inputs after performing an ajax request?
Your problem is where you put the condition. You have put out the request, and as the JS will run asynchronously, your condition runs before the return of your server. To perform at the right time,…
-
13
votes3
answers4829
viewsA: click a play button on the Youtube iframe
Include the youtube API script and replace your iframe by a div with an id to identify it: <script src="https://www.youtube.com/iframe_api"></script> <div class="editable videoMaior"…
-
3
votes1
answer153
viewsA: Change select option to URL
You can improve your logic, but I believe your mistake is just echos, for you are forgetting the character > tag option. For example this echo: value="teste Hospitalar" Teste Hospitalar Should be…
-
1
votes2
answers3385
viewsA: How to open a server file with javascript?
What you can do is an asynchronous call to the server. For example, to read a file html which is on the server, you can do so: var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() {…
javascriptanswered Oeslei 5,209 -
1
votes3
answers192
viewsA: Problem with variable concatenation
You can concatenate the string as @rray put it in the comments: $ids_ .= $id_inscrito .'|'; Remembering that you should initialize the variable $ids_ before the loop. Another point to consider is…
-
2
votes5
answers17262
viewsA: How to use ajax and php to call a function in php?
You can do something like this: JS // ... data: { funcao: 'geraSenha', parametros: [ 6, true, true, true ] } // ... PHP call_user_func_array($_POST['funcao'], $_POST['parametros']); In this case, I…
-
0
votes3
answers134
viewsA: "Undefined is not a Function" when calling "tabs"
You must have forgotten to load the plugin code. When trying to call the property .tabs, her value will be undefined and the parentheses will try to invoke it as a function, generating the error.…
-
0
votes1
answer90
viewsA: Ie8 Enable Activex Iframe Scripts and Controls crashes
The problem can be reproduced by putting a style position: relative in the element html of the page to be included on iframe. One of the solutions is to remove this style, but as sometimes you have…
-
2
votes2
answers395
viewsA: It is possible to return a vector to a javascript
The third parameter of the function post is a callback which receives server data as a parameter. $.post('envia.php', {nome: nome}, function(dados) { console.log(dados); }); On the server, you can…
-
3
votes4
answers1981
viewsA: Go to the first option after clicking the button
If you already know the value, you can set it directly by val(). $("input.bt").on("click", function () { // no seu exemplo você não colocou nenhum value // nas options, mas aqui iria o value…
-
3
votes2
answers7690
viewsA: Clear select and input fields
Create a function to clear your fields. function resetForm(idForm) { // seleciona o form a ser resetado var form = document.getElementById(idForm); // limpa todos os inputs do tipo text, password,…
-
1
votes4
answers15217
viewsA: View PHP date and time
Your problem is in strtotime what you put today, translating, hoje. Try to put now (agora). echo strftime( '%Y-%m-%e %T', strtotime('now'));…
-
1
votes2
answers99
viewsA: Events with namespace
I liked the idea of @Sergio, but I was still not satisfied. I wish I could add events natives using namespaces. I continued searching and analyzing jQuery code again, but I continue not…
-
5
votes1
answer90
viewsQ: Add properties to the [Node] element
Is there a problem with adding custom properties directly to the [Node] element? For example: document.getElementById('minhaDiv').minhaPropriedade = 'teste'; I’m using Firefox and I haven’t had…
-
3
votes4
answers53244
viewsA: Different ways to count record numbers in Mysql
Absolutely. Imagine the memory used to get 1000 products just to know the quantity. Run a count will return only one record, representing a major improvement in memory consumption.…
-
3
votes2
answers99
viewsQ: Events with namespace
I am studying about events in javascript, without using jQuery, and I came up with a question: how can I add / remove events with namespace?
-
1
votes1
answer661
viewsA: Prevent the event from being triggered 2 times
There are two ways. Using the function one. $('body').one('click', function() { console.log('Esta função será executada apenas uma vez'); }); Using the off. // removo todos os eventos do body com o…
-
3
votes3
answers1593
viewsA: Function as parameter in jQuery functions
To understand the parameters received by jQuery functions, you need to check on documentation. For example, in the function on. The simplest way to use it is as follows: .on( events, handler ) As…
-
1
votes1
answer77
viewsA: Problem in pages with size %
The problem is that you own the property left with a fixed value. For example, imagine a page with a style element left: 100px and width: 50%. If you resize it until you get the maximum screen size…
-
0
votes2
answers9275
views -
2
votes1
answer59
viewsQ: How to check on the console for open websockets connections?
I was analyzing how Stackoverflow checks for updates on the question list, but nothing appears on the console (Firebug), so I’m guessing they’re using websockets. Then I came up with a question: is…
-
1
votes2
answers2308
views -
3
votes2
answers4604
viewsA: How to insert by selecting from two different tables?
Select with php to get ids from Tabela1 and, within a loop, run the query down below. INSERT INTO Tabela3 (id, imovel, codigo, imagem_g, imagem_p) VALUES ( (SELECT id FROM Tabela1 WHERE id = $id),…
-
3
votes2
answers183
viewsA: How to apply the DRY (Don’t Repeat Yourself) strategy to this code?
You are using the same configuration for all tables. Therefore, you can simplify by selecting all tables at once. var tables = $('#em_fila, #em_digitacao, #com_erros, #em_recebimentos').dataTable({…
-
0
votes3
answers98
views -
3
votes2
answers5265
viewsA: Show/hide each element within a toggle class (jquery)
Use a container between each listing. See how it looked on Jsfiddle.
-
1
votes3
answers58
viewsA: Increase spaces when we decrease page
If I understand your layout correctly, both the bar at the top and the bar at the bottom are fixed. You have no way augment the space of the content. What you can do is add scrollbars when…
-
0
votes3
answers1117
viewsA: Validate the form without sending it
You can put the validation function in the attribute onsubmit form. <form ... onsubmit="return validarFormulario();"> </form> function validarFormulario() { var possuiErro = false; //…
-
11
votes2
answers13571
viewsA: navigate through the child elements
There are several ways to do this. You can use children or the find, optionally using some more specific selector. To traverse the elements, you can use the each. // percorre todos os filhos…
-
2
votes1
answer825
viewsA: How to add a class in html elements of a string?
Replace the method call find for filter. templateHtml = $(templateHtml).filter(".bola").addClass("futebol"); The filter filters the selected elements and the find searches within them. What happens…
-
26
votes6
answers24661
viewsA: What is the difference between declaring variables using Let and var?
As described in MDN: Let allows you to declare variables by limiting their scope in the block, statement, or in an expression in which it is used. This is inverse of the keyword var, which defines a…
-
3
votes4
answers1799
views -
1
votes2
answers1145
viewsA: Change Hidden field in form
Here’s the thing, you’re duplicating the input’s through the attribute name. You must have the two input’s of type hidden with radios and checkboxes different numbers. <!-- veja que alterei o…
-
3
votes3
answers229
viewsA: Foreach returning unconverted array
From the PHP documentation: So, $out[0] contains array of strings that Matched full Pattern, and $out[1] contains array of strings Enclosed by tags. That means in your variable $output_array the…
-
85
votes6
answers32107
viewsQ: What is Vanilla JS?
I have already found in several places this term, "Vanilla JS". It seems to be cited as a framework, but in the codes where it is cited and in the site itself the code presented is pure Javascript.…
-
6
votes1
answer1219
viewsA: Insert foreach value into a variable
Friend, you are creating 10 arrays without need. Put all with the same variable name, changing only the index. Another thing, the foreach just to go through the array, you should not put all values…
-
4
votes2
answers6436
viewsA: How to call a function of another JS file keeping the context of the current function?
You must declare the variable globally. var pagina; $(document).ready(function(){ pagina = "site1"; iniciarSite(); }); or $(document).ready(function(){ window.pagina = "site1"; iniciarSite(); });…