Posts by BrTkCa • 11,094 points
375 posts
-
8
votes2
answers238
viewsA: Image Modal only works with the first
The problem is that the two images have the same ID and is an attribute that should be unique. One option is to create any attribute and select the elements by querySelector: Would look like this:…
-
7
votes2
answers3089
viewsA: JS node - Mongodb x Mysql
A reason why the use of Node.js with Mongodb is because they both handle the same data structure natively. Node.js is a server-side javascript execution environment. Javascript works great with JSON…
-
3
votes2
answers7656
viewsA: Go through all keys of a json
Taking into account that the JSON structure is this, you can use for. in to read the keys and values of the two levels: var obj = { "logistics_provider": "{{lp_name}}", "shipper":…
-
0
votes3
answers440
viewsA: How to change the colors of Notes using javascript according to the result
After your form is uploaded, at the event window onload., you can put a function that iterates Labels (or inputs) and changes the content color according to the value. Frizando that in this case is…
-
1
votes1
answer824
viewsA: List sights via the Google Maps API
Google has an API for this, called Google Places API. You can find it here: https://developers.google.com/places/? hl=en The functions of the Google Places Javascript library allow the app search…
-
2
votes3
answers623
viewsA: pass form name to jQuery
With jQuery you check getting the event Submit of any form and then obtain the name his: HTML: <form name="form1" action=""> <input type="text" value="Olá"> <input type="submit"…
-
8
votes4
answers790
viewsA: capture value of < option > with jQuery
It is possible by the event change own jQuery get value: $('select[name="busca"]').on("change",function(ev){ var linkEnviar = "envia.php?op=" + $(this).val(); console.log(linkEnviar); }); <script…
-
1
votes1
answer97
viewsA: $. getJSON not working as it should to get image Graph API
The problem is that when directly calling the Graph api URL the return is an image, not a JSON. You will have to use the api facebook to make the call and have the return in JSON format. Something…
-
0
votes5
answers597
viewsA: JSON.stringify() method
You can map the project names in a new array using the Array#map: var projetosMembros = membros.NProjetos.map(proj => { return proj.nomeProjetos; }); var membros = {"NProjetos": [{"idProjeto":…
-
0
votes2
answers3718
viewsA: How to create a Pop UP that has the close button
You will find a lot of stuff ready, especially with Jquery. A no-add plugin option is using only css, something like: <div id="popup1" class="overlay"> <div class="popup"> <a…
-
0
votes2
answers210
viewsA: Calculate duplicate input value
With javascript you can get the previous element and the next element of a given node using previousSibling and nextElementSibling: function Calc(elemento) { var anterior = elemento.previousSibling;…
-
1
votes3
answers30
viewsA: Show different contents when selecting one of the buttons
You can leave display:none for the others in each click: $( "#Clique1" ).click(function() { $("#opcao1").css("display","block"); $("#opcao2").css("display","none");…
-
1
votes3
answers528
viewsA: Function that returns the position of the smallest number in a vector
You can use Array#indexof: var array = [1,2,3,4,5]; console.log(array.indexOf(2)); // retorna 1 var inputs = document.querySelectorAll("input"); // obtem todos os inputs var valores = []; // vetor…
-
4
votes4
answers1757
viewsA: Empty input cannot receive zero
You can iterate the input values, and the condition if(item.value) returns true if input is not: emptiness Nan Undefined blanks Thus unfilled inputs will not be considered at the time of obtaining…
-
0
votes3
answers665
viewsA: Form Validation with Submit
You can validate in the event Submit of the form, and if the user has not filled in the values of the first, the second will not be submitted. $("#form2").submit(function(event) {…
-
1
votes1
answer812
viewsA: Spring Boot does not start in Debug (Java) mode
A common error is that the application has many breakpoints.. try to remove all of them and start again in debug mode. To remove all of them, if I was on eclipse, do the following: Window > Show…
-
3
votes2
answers169
viewsA: Doubt in the statement between Arrow expression and function expression of an event
Arrow Function belongs to the Ecmascript 2015, has a shorter syntax and binds the value this lexically. An Arrow Function expression has a shorter syntax when compared to function expressions…
-
5
votes5
answers7032
viewsA: How to return the sum of numbers of an array with indices of value greater than or equal to 2
First you can get an array of values that are greater than or equal to 2 using Array#filter and then use the Array#reduce to effect the sum: function somarMaiorIgualQueDois(element, index, array) {…
-
3
votes7
answers2833
viewsA: How to check if at least one item of the array has value equal to or greater than 2
Array#some is the best option: function funcaoMaiorIgualQueDois(element, index, array) { return element >= 2; } var res = [0,2,0,0].some(funcaoMaiorIgualQueDois); console.log(res);…
-
1
votes2
answers406
viewsA: Menu link color changes when scroll is over its respective section
I believe the most assertive way for you to do this is by using the selector :have css. Something like this: #menu-mobile:houver{ background-colo: white; color: red; } You can also check the scroll…
-
6
votes3
answers16786
viewsA: Change object value
You can change by directly accessing the key: meuArray[0].name = "MarketShare"; var array = [{ name: '2015', color: 'orange' }, { name: '2016', color: 'red' }]; array.forEach(item => { item.name…
-
2
votes3
answers619
viewsA: Urls array - Next button
With Javascript, you can change the src using the function attr or prop every event click the button, this way: HTML: <iframe id="frames" src="'www.google.com" width='100%'…
-
6
votes2
answers672
viewsA: Remove comma out of square brackets - Regex
Assuming your return will have this format, you can simply: var retorno = string.replace("],","]");
-
3
votes1
answer513
viewsA: Validation of two selects
Starting from the principle that you will be working with JSON type data, but it can be in any format... you can get the event onchange in the select of states, and implement a filter in the city…
-
1
votes2
answers655
viewsA: How to Catch JSON Data with Angular
You need to enable the CORS (sorry, I did not find the same documentation in Portuguese) in your service. Then you will need to search in the documentation of the service you are using to allow it,…