Posts by LLeon • 2,257 points
66 posts
-
5
votes1
answer30
viewsA: Comparison between two objects
See if that helps you: Object.entries(dataBody).forEach(e => { if (dataDb[e[0]] !== e[1]) { dataRes[e[0]] = e[1]; } }) const dataBody = { name:'luiz', email:'[email protected]', cpf:'12345678910' }…
javascriptanswered LLeon 2,257 -
5
votes2
answers478
viewsA: Arithmetic mean in Javascript
About the prompt: Please note that the result is a string. This means that you must sometimes convert the value given by the user. For example, if the answer should be a number, you should convert…
javascriptanswered LLeon 2,257 -
3
votes2
answers2009
viewsA: Javascript - How to calculate average data in an array with multiple objects and return in another array
You can do it like this: const notasAlunos = [ { matricula: "117", nome: "Joao", materia: "x1", nota: 78 }, { matricula: "117", nome: "Joao", materia: "x8", nota: 80 }, { matricula: "117", nome:…
-
0
votes1
answer40
viewsA: Crop elements with Javascript
If I understand the question correctly, using appendChild you get what you need. const f = () => { document.getElementById('destino').appendChild(document.getElementById('elemento')) } #origem {…
-
1
votes3
answers2267
viewsA: How to draw objects from an array?
You can with Array destructuring. Following example: //gerar um Array com 30 itens para teste const arr = []; for (let i = 0; i < 30; i++) { arr.push({id: i, item: `Item: ${i}`}); } //Código para…
-
2
votes4
answers130
viewsA: String Manipulation in Javascript?
I’ll put two more options on how we can achieve the desired result: //Opção com array const arr = '0140'.split(''); arr.splice(2,0,':'); console.log(arr.join('')); //Opção com regex let i = 0;…
-
0
votes2
answers48
viewsA: Javascript, Function that groups strings according to parameter value
I arrived at this code. With the examples you gave, it seems that is ok. You would have to do other tests to see if it meets all the requirements of the exercise... function mkPretty(line_size) {…
javascriptanswered LLeon 2,257 -
2
votes2
answers271
viewsA: Allow certain characters in an input text
I think that solves: [^\d()+] const f = (ev) => { if(ev.key.match(/[^\d()+]/)) { ev.preventDefault(); } } <input type="text" onkeypress="f(event)" />…
-
2
votes1
answer362
viewsA: #Vue2 How to obtain inputs from a row in the Vuetify table?
No need to add id us inputs. Use v-model us inputs and then take the amount you need in a method that is triggered by clicking the button. Take a look at this example, I think it might help you. new…
-
0
votes2
answers62
viewsA: Update item quantity in table
One option is to put the quantity as a chave in each objeto. Then just increase/decrease the click. If that’s it, you don’t even need to create one método. Example (I added a column with the *…
-
10
votes3
answers1087
viewsA: How do I convert Filelist to Array in Javascript?
You can use Array.from() Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from document.querySelector('#files').addEventListener('change', function…
javascriptanswered LLeon 2,257 -
2
votes1
answer623
viewsA: onClick fill in input
See if that’s what you’re looking for: $(document).ready(_ => { const added = [], input = document.getElementById("RecursoTI"); $('button').on('click', ev => { const recurso =…
-
2
votes1
answer115
viewsA: Add variable to textarea editor
That’s what you need to happen? $(document).ready(function() { $('#editor1').summernote({ tabsize: 2, height: 200 }); $('.button').click(function(event) { event.preventDefault();…
-
0
votes3
answers647
viewsA: Popular HTML table from a Combobox
Suppose your data source is like this: [ {id: 1, local: 'Rua A', obs: 'xxx', agendamento: '10/10/2019' }, {id: 1, local: 'Rua Ab', obs: 'hhh', agendamento: '11/10/2019' }, {id: 1, local: 'Rua Ac',…
-
2
votes2
answers73
viewsA: How to add class with pure javascript (no jQuery)
See if this helps you: const itens = [...document.querySelectorAll('#menu li')]; const imagens = [...document.querySelectorAll('#imagens img')]; itens.forEach(i => { i.addEventListener('click',…
javascriptanswered LLeon 2,257 -
4
votes5
answers1315
viewsA: Join two events that have the same function
You can do it like this: HTML: <input type="text" onclick="funcao()" onkeydown="this.click()"> JS: const funcao = _ => alert(1); But I would do so: const funcao = _ => alert(1), input =…
-
2
votes1
answer131
viewsA: Button when clicking blue blink
You can use the following CSS property for the element: -webkit-tap-highlight-color: transparent; -Webkit-tap-Highlight-color is a non-standard CSS property that defines the highlight color that…
-
1
votes1
answer222
viewsA: Help to get decimal value of mask input (Ionic 3 + br Masker)
You need to treat your string. Remove the dots and replace the comma with a dot. const n = '2.368,67', nG = '256.695.693,25'; console.log(n.split('.').join('').replace(',','.'));…
-
0
votes3
answers1347
viewsA: How to create a clickable link within another
As already said, it is not recommended to use the tag <a> this way, but take a look at this Fiddle if you want to use like this: https://jsfiddle.net/gyurjf5k/ You can get the result you need…
-
1
votes1
answer48
viewsA: Creating a slider with Jquery
In addition to the click event, I would also like the images to automatically change preserving the click order. This example can help you. I made the comments in the code itself. $(function() { /*…
-
1
votes2
answers69
viewsA: enable option in select
This example can help you: $('[data-canal]').click(function() { const el = $(this); $(`#selectChannel option[value="${el.data('canal')}"]`).prop('disabled', false); el.remove(); }); p { cursor:…
-
1
votes2
answers47
viewsA: How to add class to specific elements?
Alter your JS to catch the tag figure that surrounds the clicked button: $(document).ready(function(){ $( ".moreinfobtn" ).click(function() {…
-
0
votes1
answer90
viewsA: Group JSON data (sent by multiple devices) by date
See if this helps you. Instead of returning each object like this: {2019-06-12 12:45:50: {id: "ab1", value: "31"}, {id: "cd2", value: "34"}} Returns like this: {date: "2019-06-12 12:45:50": [{id:…
-
0
votes5
answers76380
viewsA: How to pin a "horizontal menu" to the top of the window when scrolling the page?
It can be achieved only with CSS assigning the value sticky to the property position: #menu { position: sticky; top: 0; } The compatibility of the feature is very broad, but it seems that it does…
-
0
votes1
answer78
viewsA: input.Select2 does not let you select the record
I believe the problem lies in the code snippet where you are processing the results: processResults: function (data) { return { results: data.results.map(x => ({ dis_id: x.dis_id,//<---------…
-
1
votes4
answers486
viewsA: Replace a specific character in a <input type="text">
You can use replace with RegExp: document.querySelectorAll('.area-input > input').forEach(i => i.value = i.value.replace(/'/g,' ')) Or split with join: document.querySelectorAll('.area-input…
-
2
votes2
answers208
viewsA: Do not allow repeating values in different dropdownlists using jQuery?
Each time the event occurs change of a select, you create a Array with all values that have already been marked. Then you can use the method $.inArray() to disable the options whose values are in…
-
0
votes2
answers451
viewsA: How to remove white space
var ola = '123 456 789'; ola = ola.split(' ').join(''); console.log(ola); …
javascriptanswered LLeon 2,257 -
0
votes2
answers304
viewsA: SQL query unifying 3 tables
If you are using the MS SQL Server can do so: select A.nome, B.terrenos, C.conversas from users as A cross apply (select count(1) as terrenos from terrenos where iduser = A.id) B cross apply (select…
-
0
votes3
answers4839
viewsA: SQL script to create mask
It is possible to arrive at the result with stuff. update [tabela] set [coluna] = stuff(stuff([coluna],5,0,'.'),8,0,'.') Operating here: SQL Fiddle…
-
2
votes3
answers992
viewsA: Concatenate elements
Use jQuery itself. So just: $('<div/>', {id: valorID}).css({'position': 'absolute', 'left': valorPosicao + 'px'}).prependTo('body'); Follow example to run. In the console appears the div…
-
2
votes1
answer481
viewsA: Syntax error in with SQL Server
When using with, you need to use semicolon after the previous command. declare @data date='2018-05-21';
-
1
votes3
answers518
viewsA: Remove JQUERY tags
As you are using jQuery, you can treat the field like this: var msg = $('input').val(); //retira as tags $('<p/>').html(msg).text(); //faz encode das tags $('<p/>').text(msg).html();…
-
0
votes3
answers81
viewsA: HTML and AJAX problem
Depending on the server configuration, any attempt to send < or / by form may return error. I use jQuery itself to handle sending characters to the server. Test like this and see if it’s okay:…
-
0
votes2
answers145
viewsA: Problem when calculating percentage using parseFloat and toFixed
Can also be used split and join to convert the fields. I put snippet to illustrate. function calculo() { var pv =…
-
1
votes2
answers109
viewsA: Ajax parameters are coming as Undefined
I didn’t see in the code how you’re setting the attribute data button #btnExcluirNotificacao. But you can try it like this and see if it works: //Ajax para remover uma notificação, e atualizar a…
-
0
votes2
answers182
viewsA: Write data to a based table and two other tables
I think it works: declare @query nvarchar(max), @nome varchar(50) declare @temp Table (nomecoluna nvarchar(50)) --SALVE OS REGISTROS COM OS NOMES DAS COLUNAS EM @TABLE insert into @temp select *…
-
1
votes2
answers39
viewsA: How to correctly display data from a commemorative date table
See if this helps. select * from ( select cast('2018/' + cast(mes as varchar) + '/' + cast(dia as varchar) as date) as [data], descricao from @table ) Q where [data] between '2018-01-15' and…
-
2
votes2
answers3901
viewsA: Currency Mask with jquery
Without doing any validation, just to get what you quoted. $('input').on('keyup', function() { var v = $(this).val(); if (parseInt(v.length) === 3) { $(this).val((v * 1000).toLocaleString('pt-br',…
-
0
votes2
answers236
viewsA: problem with click event reference inside a div
To the extent that the divs, assign the event click. $('<div id="box_pesquisa_'+contador+'"> nova div '+contador+'</div>').appendTo(div) .on('click', function() {....}); Example: var div…
-
1
votes1
answer1076
viewsA: Manipulate the Scroll event in Jquery
You can define the style rolling up. When rolling down, remove the style thus leaving the tag nav as defined in the style sheet. I used style = border: 1px solid just to facilitate the visualization…
-
85
votes12
answers79762
viewsA: Formatting Brazilian currency in Javascript
Solution with toLocaleString(). var atual = 600000.00; //com R$ var f = atual.toLocaleString('pt-br',{style: 'currency', currency: 'BRL'}); //sem R$ var f2 = atual.toLocaleString('pt-br',…
javascriptanswered LLeon 2,257 -
1
votes2
answers286
viewsA: format value with javascript
Alternative, only with the use of slice and join. var teste = "006BC953F26DAC56C51D61"; var formato = [ teste.slice(0,4),teste.slice(4,9),teste.slice(9,13),teste.slice(13,18),teste.slice(18)…
-
0
votes2
answers401
viewsA: Get element position based on another
var p1 = $('.elementoSecundario').offset(); var p2 = $('.elementoSecundario').position(); var X = (p1.left - p2.left); var Y = (p1.top - p2.top) X is the horizontal displacement in relation to the…
-
9
votes1
answer2099
viewsA: How to Catch Unix Timestamp with Javascript?
Right. All we had to do was round up. Timestamp in milliseconds: +new Date() //que é o mesmo que new Date().getTime() Timestamp in seconds: Math.floor(+new Date() / 1000) //que o mesmo que…
javascriptanswered LLeon 2,257 -
2
votes1
answer3861
viewsA: Clear fields from a form
HTML explicitly prohibits the insertion of form within another form. see here In this part: Content model: Flow content, but with no form element Scendants. In this highlighted part of the link, is…
-
1
votes1
answer1100
viewsA: Select Datatable Line via Javascript
If you are using the Plug-in datatables for jquery you can do so: var tabela = $('table').DataTable(); var linha = tabela.rows(n).nodes(); //onde n é o index da linha que deseja selecionar. Follow…
-
1
votes3
answers955
viewsA: change soon when decreasing screen width
$(window).on('load', function() { if (window.screen.width < 800) { $('#minhaImagem').attr('src','img/logo2.png'); } }); With only CSS you can too. But with jquery can do so.…
-
1
votes1
answer95
viewsA: Select a badge as a Jquery child element
Tiago, if you want to insert some content into the element button and the element span, you can do so: $('button').prepend('Nome'); $('span').text(1);…
-
0
votes3
answers759
viewsA: Replace in substring in c#
If the two sets of final numbers are always the same, as in the example, you can do so if you do not want to be stuck to the length of the string. var s = "E02000000000000002DOCE LUAMAR MORENINHA…