Posts by BrTkCa • 11,094 points
375 posts
-
0
votes3
answers62
viewsA: Click for more than one item
You can check which button was clicked to change the visibility. var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.conteudo1 = false; $scope.conteudo2 =…
-
0
votes2
answers112
viewsA: Chartjs - Chart going only 1 time
The canvas is with the same id to host different charts. Each chart should be unique; it could be done so: <canvas id="GraficoDonut1"> ... <canvas id="GraficoDonut2"> ... And change the…
-
0
votes2
answers1099
viewsA: Include or Require in Nodejs to separate codes
With ES6 the syntax is different and can provide some other features, such as the import being asynchronous and being able to import only parts that are needed. Syntax Foobar.js export function…
-
1
votes3
answers372
viewsA: How to catch a class with Jquery array?
It is possible to scroll through each item and manipulate it using $.each: $(".benefits li").each(function(idx, item){ // para pegar console.log($(item).text()); // para alterar $(item).text("texto…
-
1
votes2
answers1155
viewsA: Mysql with Nodejs: insertion of records
The ideal scenario is to separate the database connection file to implement some kind of Singleton, something like that: Connection.js const mysql = require('mysql'); var single_connection;…
-
4
votes3
answers1085
viewsA: How to insert row at the top of a table using JS?
Instead of append use the prepend and put a tbody to separate body header: ... $("#tabelaProducao tbody").prepend(linha); Example var linha = "<tr>"; linha += '<td class="cnes"> Item' +…
-
5
votes3
answers124
viewsA: Callback running when loading the page
If the function is not anonymous it will be invoked in the event record. In your case, you can invoke nome_existe within an anonymous function on callback of blur: function nome_existe(element) {…
javascriptanswered BrTkCa 11,094 -
0
votes2
answers319
viewsA: Select combobox from a click on the table row
The problem is that it is leaving selected options old, you can reset the tags before selecting again: $('option').removeAttr('selected'); var setores = [{ "id": "1", "setor": "Recepcao" }, { "id":…
-
3
votes2
answers431
viewsA: Get all the ID of the elected in jQuery
You can use the not: $('div[id^=menu').click(function() { // indica qual item não deve ser removido $('div[id^=menu').not($(this)).removeClass('open'); visualizar(); }); // apenas visualizacao…
-
1
votes2
answers39
viewsA: How to return these values outside the Array?
With map is the best choice if you’re going to forEach could even be something like: var arrayAdicional = []; item.ingrediente_adicional.forEach(function(ingrediente){…
javascriptanswered BrTkCa 11,094 -
1
votes1
answer70
viewsA: Problem with JSON filter and Array
Assuming that it is necessary to filter the stretches that contain the flight of the selected company, it could simplify the filter to check if there are flights in the stretches that are selected:…
-
1
votes1
answer95
viewsA: I want to click on a link when I click show a div and when I click on another link show another div and disappear the previous one
You can check which link is being clicked to "togglar" to div correct: $(".teste").click(function() { if ($(this).attr('id') == 'link1') { $("#div1").toggle(); $("#div2").hide(); } else {…
-
3
votes2
answers10476
viewsA: Pick up value or button name with Jquery
You can get the properties of the button directly on click. Some properties are possible with attr or prop. And then assign to the textarea. Example $('button').click(function(){ var valor =…
-
1
votes2
answers44
viewsA: Problems validating balance
The comparison is being made between strings, you can cast to Number: var saldo = parseFloat($($('#tbPimItem tbody tr td').get(7)).text()); var qtde = parseFloat($(this).val());…
-
2
votes1
answer106
viewsA: Alert in only certain browser
It is possible to get browser properties: function identificarBrowse() { var nav = navigator.userAgent.toLowerCase(); if (nav.indexOf("msie") != -1) { alert("IE"); } } Note The way to identify IE11…
-
3
votes2
answers1415
viewsA: Algorithm to capitalize the first letter of each word
This function traverses the words of a string, taking into account the space and swapping the first character for the main: function capitalizeFirstLetter(string) { return string.replace(/\w\S*/g,…
javascriptanswered BrTkCa 11,094 -
3
votes1
answer801
viewsA: Insert an element into an array that contains an object
You can only assign before doing push: this.array = []; email.mensagem = res.data[0].Mensagem; this.array.push(email);
-
3
votes1
answer86
viewsA: JS: not defined function error (when calling one function inside another)
Use the this to indicate the scope of the function: var obj = { init: function() { this.minhafuncao(); }, minhafuncao: function() { console.log("oi"); } } obj.init();…
-
2
votes2
answers81
viewsA: Function that returns an array of strings that are in all arrays
A more "manual" version because you will have to iterate all the items of the first array. Example var objetos = ["abridor de garrafa", "abridor de latas", "adaga", "ábaco", "abajur", "abotoadura",…
-
2
votes4
answers596
viewsA: Progressive counting using for
You can pass arguments to the function: var span = document.querySelector('span'); for (var i = 0; i < 10; i++) { setTimeout(function(a) { span.innerHTML = a; }, i * 1000, i); }…
-
1
votes5
answers5036
viewsA: Join two Jsons into a single object
You can assign: var json1 = { "razao_social":"INTELIDER","nome_fantasia":"INTELIDER LTDA","rg_insc_estadual":"123456"} var json2 = { "usuario":{"login":"gleyson","senha":"987654"} } json1.usuario =…
-
0
votes4
answers11999
viewsA: Take the lowest value and the highest value of an array with Javascript?
You have to convert strings into numbers before making comparisons: var arr = ["885.9", "984.9", "444.9", "528.9", "528.9"]; var maior = Number.NEGATIVE_INFINITY, menor = Infinity;…
-
2
votes4
answers5086
viewsA: How to add values of a column in the table?
Another way of doing, taking into account the index of each item in the column: var posicao = 2 , total = 0; $('table tbody td').each(function(a,b){ if (a == posicao) { total += Number(b.innerHTML)…
-
0
votes4
answers1734
viewsA: Add a sequence of numbers
Has two problems: parseint returns an integer in the specified base The sum variable needs to be initialized var numero; var soma = 0; for (var i = 0; i < 7 ; ) { numero=prompt("Entre com o…
javascriptanswered BrTkCa 11,094 -
1
votes1
answer724
viewsA: Writing Html using javascript
Between using join or concatenation, concatenating performs better, but the writing of the code can be more meaningful, especially when using ' with " and when there are many lines. In that test,…
-
0
votes2
answers177
viewsA: Changing frame width with mouse over javascript
Or with javascript: var frame = document.getElementById('frame'); frame.onmouseover = function() { frame.style.width = '600px'; frame.style.height = '20px'; } #frame { width: 300px; height: 250px; }…
-
7
votes3
answers9259
viewsA: Time difference between two dates with Javascript?
Manually with javascript, you can create a date from the string, picking separately year, month, day, minute and second, and then calculate the difference between dates (and minutes and seconds).…
-
3
votes1
answer247
viewsA: input and javascript tag
This is because Htmlinputelement.value will return a string. You could use HTMLInputElement.valueAsNumber: Example function updateOrder() { var numCake =…
-
2
votes1
answer127
viewsA: Update contents of a. load()
In the GET and POST security category, the difference is that GET exposes the data in the URL and POST, among some other peculiarities of semantics and structure. You could pass the information via…
-
2
votes2
answers1432
viewsA: Query return in Javascript variable
This is because Node.js is asynchronous, so it does not wait for the result between one instruction and another (in case of asynchronous methods). What you can do is when you fall in callback call a…
-
3
votes3
answers5951
viewsA: Add inputs with jquery and real time
If by "real time" you mean when typed, here’s an example with keyup which is the event triggered when the user releases a key on the keyboard: $(document).ready(function() {…
-
2
votes3
answers414
viewsA: How to remove specific word from string?
You can use index: let uri = 'meusite.com' // -1 é não encontrado if (uri.indexOf('http://') == -1 && uri.indexOf('https://') == -1){ uri = 'http://' + uri; }…
-
1
votes2
answers1683
viewsA: Position cursor at the end of text by clicking input
Another alternative, with Javascript: <input onfocus="this.selectionStart = this.selectionEnd = 500;" value="Olá texto">…
-
0
votes1
answer29
viewsA: Data editing problem - Angularjs
If the scope variable is being used in more than one place, if modified, it will show the change where it is being applied to view, due to data Binding which automatically synchronizes the data…
-
1
votes3
answers1587
viewsA: Redeem input file name and assign input text
I don’t know if it is the best, but with jQuery it is possible to recover the files by event change: $('[name="file"]').on('change', function(){ $('[name="name"]').val($(this)[0].files[0].name); });…
-
1
votes2
answers39
viewsA: Is it possible to change the click function to another function type?
Could isolate in another function: function invoke(){ contosoChatHubProxy.invoke('newContosoChatMessage', $('#displayname').val(), $('#message').val()); } And invoke in done:…
-
0
votes1
answer1182
viewsA: Chartjs with PHP
The format of the return data has two details that need to fit the charjs, who are: the property data expects an object instead of an array the property datasets expects an array instead of an…
-
0
votes2
answers73
viewsA: Insert idented HTML into jQuery
Another way to insert multi-line texts is with strings template of ES6. To declare a template string it is necessary to involve the text by crases, thus: `<div class="filters"> <div…
-
0
votes3
answers4799
viewsA: How to remove clasps in a regex?
Use scape (\), would look like this: /\[.!'@,><|://\\;&*()_+=\]/g Example: http://regexr.com/3g2hg…
-
1
votes2
answers98
viewsA: Why doesn’t $.post() return an object?
The appropriate solution is of that answer, but there is another alternative that is JSON.parse: var txt = '[{"title":"Título de teste","thumb":"2","views":"920134"},{"title":"lorem ipsum teste…
-
2
votes1
answer521
viewsA: How to create javascript array object within a FOR?
Could store objects in array using Array#map: var habi = []; var valores = [{ "idhabilidade": 1, "descricao": "Descricao 1" }, { "idhabilidade": 2, "descricao": "Descricao 2" }] habi =…
-
1
votes2
answers363
viewsA: how to find if it contains text inside a javascript array
You can scroll through the array of responses using forEach and save position when find: var perguntas = [], respostas = []; perguntas[0] = "que sao dinossauros"; respostas[0] = "Constituem um grupo…
javascriptanswered BrTkCa 11,094 -
3
votes2
answers73
viewsA: Insert idented HTML into jQuery
Because from the moment it is a new line it is a new statement, in which case you need to concatenate the lines to be true as only an instruction: $j('<div class="filters">' + '<div…
-
3
votes1
answer573
viewsA: Differences between authentication types
Basic It is a method that the User-Agent (a line of text that identifies the browser and the OS for the web server) uses to provide user name and password when making a request. It is the simplest…
-
2
votes2
answers189
viewsA: mongodb getNextSequence error is not defined
You need to save the function before and then load it, as @Cigano suggested: db.system.js.save( { _id: "getNextSequence", value : function (name) { return x; } } ) And then: db.loadServerScripts();…
-
1
votes2
answers2568
viewsA: How to use Materialize with Angular?
It is not indicated to merge the two (jQuery and Angular) if the wish is to change the DOM via jQuery within an Angular application, as this should be done via directives, because Angularjs comes…
-
5
votes1
answer833
viewsA: Display selected option in select with JS
The target the selector is not correct, one way is to get the direct value by the element event: $("select[name='estado']").change(function() { var estado = this.value; alert('estado ' + estado);…
-
8
votes1
answer5183
viewsA: How to disable click out of modal?
You can set the property data-backdrop="static" to your modal: <div class="modal hide" data-backdrop="static"> And if you wish to disable ESC also use data-keyboard="false": <div…
bootstrap-3answered BrTkCa 11,094 -
0
votes1
answer329
viewsA: Facebook Graph API - How to post to a page?
It is necessary to have the permissions: publish_actions manage_pages The id page and access token are requirements. Not tested, but I believe it is important to get the page access token to use on…
facebook-graph-apianswered BrTkCa 11,094 -
3
votes2
answers143
viewsA: Input event only happening when loading the page
An option could be to get the direct value of the element without having to store in a variable: var frase = 'TESTE'; $(".campo-digitacao").on('input', atualiza); function atualiza() { if…