Posts by vik • 2,208 points
88 posts
-
-2
votes2
answers243
viewsA: Switch Case with Java Script and Checkbox
Another option would be to search for example the class uber return the selected. Consider using a radio instead of a checkbox. function executar() { const nodelist =…
-
2
votes1
answer85
views -
-1
votes1
answer60
viewsA: Breaking text using div
You can use the property text-indent in the text to indent the first line, and use position: absolute; in the circle. .circulo { border: 1px solid #000; border-radius: 25px; width: 25px; height:…
-
2
votes2
answers114
viewsA: Width defined in css appears as Undefined for Javascript
elem.style.width returns the width set by javascript. ex: function increaseBar(elem){ elem.style.width = '150px'; // já aparece 150px console.log("Largura no css: "+elem.style.width) } Can use:…
-
2
votes1
answer590
viewsA: How to make a div appear by clicking javascript button
The method getElementsByClassName returns a collection. You would have to refer to the collection’s Journal. document.getElementsByClassName(el)[0].style.display = "block"; ↑↑↑…
-
1
votes3
answers2267
viewsA: How to draw objects from an array?
The idea here is while the array options has elements, will be drawn a number (from zero to last Dice) that will be the element of index to remove from the array options. Then added to the…
-
1
votes3
answers945
viewsA: How to get the biggest word from a string in Javascript?
One more way using regex, sorting by word size and picking the first element. const string = "Bom dia a todos!"; const result = string .match(/\w+/g) .sort((a, b) => b.length - a.length)[0];…
javascriptanswered vik 2,208 -
1
votes1
answer851
viewsA: Scan array via javascript and remove duplicate objects with Map
You can compare whether 2 objects "are equal" convert both to a JSON string. const array = [ { "amount": 6, "codes": ["BRCH", "ARSI", "ENSI"] }, { "amount": 6, "codes": ["BRCH", "ARSI", "ENSI"] }, {…
-
0
votes1
answer59
viewsA: How to solve these two problems in my code?
For the first problem in css #ballon can reduce time or remove line: transition: left 250ms linear; For the second problem in oninput button control: Stay with the Ballon fully within the projection…
-
1
votes2
answers343
viewsA: Doubt in the for and if
That sequence of numbers (1, 2, 3, 6, 7, 14, 15) has the pattern of 'double', 'plus 1', 'double', 'plus 1'... Then we will have to use a variable that alternates its state but has only two possible…
javascriptanswered vik 2,208 -
0
votes1
answer58
viewsA: Difficulty in using LAG to catch the percentage of monthly evolution
CREATE TABLE IF NOT EXISTS `campanha` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ano_mes` date DEFAULT NULL, `transacoes` int(255) DEFAULT NULL, PRIMARY KEY (`id`) ); INSERT INTO campanha (ano_mes,…
-
1
votes1
answer27
viewsA: Take the rest of the decimal places and perform a conversion
You can use the module operator % that returns the rest of the division... 9 % 3 // retorna 0 10 % 3 // retorna 1 11 % 3 // retorna 2 12 % 3 // retorna 0 So if you divide the result of the module by…
-
6
votes3
answers2052
viewsA: Convert a comma-separated string to a multidimensional array
Every three commas it replaces with #, then separate by # and , converting to Number const str = '1789, 3, 8 , 1788, 3, 8, 1790, 3, 9'; let index = 0; const result = str .replace(/[,]/g, _ =>…
-
0
votes1
answer30
viewsA: Chosen-select Onclik event
The tag option does not support the event onclick. If you want access to value of option can use the event onchange on the tag select: function teste(value){ alert(value); } <select id="select"…
-
0
votes3
answers88
viewsA: Textarea that calls a User List when the F2 key is pressed
Another example that can help! const users = ['maria','rita','joana']; function myFunction(event){ if (event.keyCode === 113){ document.getElementById('users').classList.add('show'); } } function…
-
5
votes3
answers166
viewsA: Create function in javascript
Another option would be to use the method charAt() The charAt() method returns the specified character from a string. If the index you provide is outside the index range of the string, Javascript…
javascriptanswered vik 2,208 -
0
votes3
answers291
viewsA: Javascript character limit to full stop
This is not a direct answer to your question, but it might be useful. .container{ width:300px; } .single-line{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background-color:…
-
0
votes3
answers41
viewsA: Sidebar open at the place I click?
on the line: <a href="#" onclick="openSlideMenu()"> remove: href="#" getting: <a onclick="openSlideMenu()"> the same in closeSlideMenu() not to go up when closing.…
-
1
votes3
answers168
viewsA: Add and remove class when using pure Javascript getElementById
You can use a global variable to store the id ativo, or save the element itself, and when set a new element ativo you remove the class from the variable element and arrow that variable with the new…
javascriptanswered vik 2,208 -
4
votes2
answers377
viewsA: Game of popping polka dots on the screen
One idea would be to have access to the coordinates (left and top) of each ball. You can have a collection with all divs bolas using: var bolasDivs = document.getElementsByClassName('bola'); To have…
-
0
votes4
answers1230
viewsA: Put smooth transition with Javascript
Experiment with opacity function toggleDiv(){ let div = document.getElementById('minha-div-1'); div.classList.toggle('hide'); } .minha-div{ opacity: 1; transition: opacity 1s ease-out; }…
-
1
votes4
answers180
viewsA: How to remove the last space in each line from a textarea?
function formataTextarea() { var lines = document.getElementById('text-area').value.split('\n'); var formated = []; // Percorre…
-
0
votes1
answer874
viewsA: Update field of a selection of an object array with filter
Uses the reduce and creates a new array. See if it helps: const array = [ { 'id': 1, 'b': 2, 'c': false }, { 'id': 2, 'b': 2, 'c': false }, { 'id': 3, 'b': 2, 'c': false }, { 'id': 4, 'b': 2, 'c':…
-
2
votes2
answers94
viewsA: Get the number of rows and turn into Divs
Without the use of jquery you can do something like this: function criarDivs(input){ // TODO:: validação do input let total = document.getElementById('input').innerText; for (let i=1; i<=total;…
-
1
votes3
answers820
viewsA: How to do when the person takes the mouse from the top decrease the size only with css
This example increases the div when the mouse is on top, and returns to the original size when the mouse leaves the div. .post{ width:100px; height:100px; background-color:#dddddd;…
-
0
votes4
answers114
viewsA: Hide a DIV based on the value of a field
Try calling the event function when pressing. <script type="text/javascript"> $(document).ready(function () { var toogleDivAcidente = function () { if (this.value == 'Acidente') {…
-
0
votes1
answer326
viewsA: Insert text to a textarea without modifying text that already exists with input
You can use a global variable to store the value of #i5 and concatenate like the others... the event also changed to keyup. var i5text = $('#i5').val(); $(function() { function updateTextarea() {…
-
1
votes1
answer82
viewsA: Why is the variable not accessed outside the function?
The problem is that when you put the line var nome1 out of function, this code is executed as soon as the page loads and its input is empty, so the var nome1 is empty, so when the function is…
-
1
votes2
answers437
viewsA: Extract objects from an object array to create a single object with all items
Another option using Object.assign() and reduce(): let source = [ { cachorro: 'Bob', gato: 'Mica' }, { dono: 'Jose', dona: 'Maria' }, { outros_animais: 'sim', animais: ['cavalo', 'vaca'] } ]; let…
javascriptanswered vik 2,208 -
0
votes1
answer96
viewsA: How to solve this problem in the collision?
The collision between squares and rectangles occurs when the left (coordinate where it starts to be drawn) from OBJECT TO is smaller than the left plus the width (width) of subject B and the left…
-
10
votes2
answers1797
viewsA: Is there any way to decrease the amount of Else and if?
Can use a dictionary alternatively: var idade = 12; var dic = new Dictionary<int, string> { { 6, "Infatil A" }, { 7, "Infatil B" }, { 10, "Juvenil A" }, { 13, "Juvenil B" }, { 18, "Não existe…
-
2
votes2
answers107
viewsA: Use "Array.prototype.filter" to list what you do and what is not part of the condition
This example does not use filter(), uses reduce(): let a = { "data": [ { "item": 1 }, { "item": 2 }, { "item": 3 }, { "item": 4 }, { "item": 5 }, { "item": 6 } ] }; let sample = [1, 2, 3]; let…
-
2
votes1
answer90
viewsA: Select text in front of the current text using Textbox
The textbox has an auto complete mode, which differs from what it prefixes is that it only takes the start string. public Form1() { InitializeComponent(); this.textBox1.AutoCompleteMode =…
-
2
votes1
answer319
viewsQ: Animation to move image inside a span
I have a div with the id="origem" which contains an image of a star, how can I move the image to the span with the id="destino" using an animation of for example 2 seconds, the path has to be in a…
-
1
votes1
answer236
viewsA: Declare a two-dimensional array in javascript with no position number specified
There are no multidimensional arrays in javascript, there are nested arrays (Jagged array), which are arrays within arrays. You do not need to specify the size of the array, even if you specify a…
-
1
votes2
answers95
viewsA: Problem with LINQ
The idea here will be to create an object of anonymous type to assist sorting, with the filename and value to sort... this example takes into account that the value to sort is always between the…
-
3
votes1
answer89
viewsA: Sort and sort a string
With Linq is a short code: var allChars = "abcdefghijklmnopqrstuvwxyz_0123456789"; var bigString = "u2wlcn7cj0ej0u2d14kmylhm311mpj0f44k7m9hvz j0xep9vgbbox4kn4kf4o8g5h4kvzxr4kmha898gha…
-
2
votes1
answer65
viewsA: Group by date and receive total records of each date and assemble another matrix
Two examples that seem to work... var origem = [ { data: "23-04", xxx: "xxx", yyy: "yyy" }, { data: "23-04", xxx: "xxx", yyy: "yyy" }, { data: "23-04", xxx: "xxx", yyy: "yyy" }, { data: "23-05",…
javascriptanswered vik 2,208 -
4
votes4
answers474
viewsA: Grab part of a string
I leave here another alternative, and with the execution times of 10,000,000 times. string texto = "Ninguem ninguem, todos"; string resultado = texto.Substring(0, texto.IndexOf(',')); // 0.383s…
-
3
votes1
answer60
viewsA: Display runtime of an application [C#]
An idea would be to create a Datetime when initiating the form, and within the event Tick of a timer, for example with the Interval a 1000 (1 second), subtract this Datetime with the current…
-
0
votes3
answers73
viewsA: Mark All Checkbox in a groupbox
One more solution if the groupbox does not contain only checkboxs: groupBox1.Controls.OfType<CheckBox>().All(chk => chk.Checked = true);
-
2
votes1
answer56
viewsA: Method to move picturebox in an array
The problem with error is that the peça_selecionada is always -1, -1 when you enter the else of if, because it is always creating the instance in the event, it should be created in the scope of the…
-
6
votes2
answers186
viewsA: How to convert Two-dimensional array to a Single array?
You can cast.. won’t be the most efficient but it’s simple: int[] array1d = arrayBidimensional.Cast<int>().ToArray();
-
1
votes2
answers245
viewsA: How to make a Class property of another Class? C#
Missing property name or type: public Motorista {get; set;} public Veiculo {get; set;} Seria: public Motorista Motorista {get; set;} public Veiculo Veiculo {get; set;} You also need to instantiate…
-
1
votes1
answer80
viewsA: Align column to right pdfsharp
The method DrawString has an Overload that accepts a StringFormat. ex: var format = new StringFormat { Alignment = StringAlignment.Far, }; graphics.DrawString("texto", font, Brushes.Black, new…
-
1
votes1
answer155
viewsA: How to change the properties of a Form being inside a Usercontrol that is not in the Form? C#
You need the instance of yourself Form1 (for example, passed by parameter to the usercontrol), an instantiation created within your usercontrol is a different object than the one already created.…
-
2
votes1
answer528
viewsA: How to correctly fill a Listview with <List> C#
You are using Overload string text adding a new line with only one string: materialListView1.Items.Add(item.Placa.ToString()); What you want to use is Overload ListViewItem value, which in turn has…
-
1
votes3
answers676
viewsA: Factor of a number chosen by the user
You need two cycles, one to calculate the factorial, and the other to accumulate the value. Console.WriteLine("A expreção 1 + (1/1!) + (1/2!) + (1/3!) + ... + (1/n!)"); Console.WriteLine("Digite a…
-
0
votes1
answer963
views -
5
votes1
answer71
viewsA: How do you put that in a for cycle?
It is not very clear what you want, but if you want to replace this long line with a cycle for, can do so: int count = 0; for (int i = 1; i <= 9; i++) { if (this.Controls["label" + i].Text !=…