Posts by DontVoteMeDown • 2,535 points
52 posts
-
1
votes1
answer585
viewsA: Calling input value within span
Try this: <input type="text" class="form-control" id="usado" placeholder="Quantidade" aria-describedby="basic-addon1"> <span class="input-group-addon" id="basic-addon1"…
-
0
votes3
answers1963
viewsA: Javascript, save the initial values of the variables
Simple, because you are always reading the current html using pad.innerHTML. You’d have to keep the value of html at the beginning, not the reference of the: var pad =…
-
3
votes3
answers8495
viewsA: Simulate click when opening the page
Just call the click() an element. Example: document.getElementById("meuElemento").click(); Where meuElemento is the id of any element in html, as long as it has an event click, such as elements…
javascriptanswered DontVoteMeDown 2,535 -
2
votes3
answers466
viewsA: How to detect if an element is accompanied by text with jQuery?
I think I found a way: var list = $(".box").filter(function(i, el) { return Array.from(el.childNodes).filter(function(cn) { return cn.textContent.trim() != "" && cn.nodeType == 3; }).length…
jqueryanswered DontVoteMeDown 2,535 -
3
votes1
answer1762
viewsA: Autocomplete: JSON + PHP
This is because you are only getting the first record returned by the query. You have to iterate on the result: $query = $mysqli->query("SELECT country_name FROM countries WHERE country_name LIKE…
-
2
votes1
answer440
viewsA: Slide control (in div) with jquery - next and Prev function?
I changed your code a little bit: var interval = setInterval(function(){ change("next"); }, 3000); var change = function(fn) { $ds.filter(':visible').fadeOut(function(){ var $div =…
-
6
votes1
answer71
viewsA: Select brings different results
Group sql conditions with (): SELECT * FROM documento WHERE idAdministrador = '1' AND (modulo = 'funcionario' OR modulo = 'atestado') Otherwise it was probably being interpreted as idAdminstrador=1…
sqlanswered DontVoteMeDown 2,535 -
2
votes1
answer342
viewsA: Change tab via button
Here a very simple code: $(".proximo").on("click", function() { var indice = $('#tabs ul li a[href="#' + $(this).parent().prop("id") + '"]').parent().index(); $("#tabs").tabs("option", "active",…
ajaxanswered DontVoteMeDown 2,535 -
3
votes1
answer1148
viewsA: on('click') running more than once
In fact it will occur every time the event click element area is clicked. It may be that the .mais1 is inside it, so it may seem like clicking on it, but not necessarily. What you can do is take the…
-
1
votes3
answers347
viewsA: Retrieve the input from a class array with javascript
The way you are registering the event is not correct. You cannot pass a function running she: message(i). The parentheses run it and what would be recorded would be the return of it. To pass a…
-
8
votes1
answer5374
viewsA: JS code problem (Uncaught Syntaxerror: Missing ) after argument list)
You have to escape double quotes inside a double quote string, example: "\"string dentro de uma string\"" So in your code: document.write("<div id="chatbox_ret_cont" class="chatbox_" +…
-
4
votes2
answers1314
viewsA: Note Field Mask - 10 or 5.5
If I understand correctly, you want to format the field with a decimal place. Try this code: $("#valor").on("change", function() { this.value = Number(this.value.replace(",",…
-
3
votes2
answers4643
viewsA: How to remove characters from a certain point with Jquery?
Solution with regex: "smartphones?marca=3".replace(/.+\?/g, ""); Fiddle
-
2
votes1
answer45
viewsA: How to maintain orderly list of records in relationship N:N
Just save the order in the relationship table (intermediate), so you know the order for each author of that publication. Demo…
-
1
votes2
answers494
viewsA: Save variable in Javascript and pass in getjSon URL
It seems to me that you are creating two events for the same button #brn_entrar. Just merge the codes. You take the field value and put it into the variable matricula, then call the getJSON…
-
5
votes2
answers5337
viewsA: How to filter data from a JSON with JS?
I made a simple code in pure JS based on your form. It’s very simple, I would have to improve: Being json the variable with the json of your data, select the combo where values are the name of the…
-
1
votes2
answers505
viewsA: Set value for combo with Ajax
There’s probably an error in your console, as I suspect that the moment you try to access document.getElementById(id) where the id is equal to situacao, is not found because your combo has no id,…
-
2
votes2
answers67
viewsA: Return image value
I don’t know exactly why it didn’t work but I suspect it’s because the tag img does not work with the attribute value. This attribute is used in form elements. So if you change the .val() for…
jqueryanswered DontVoteMeDown 2,535 -
4
votes2
answers768
viewsA: Chaining of asynchronous requests
I think it would be right to start a request only when another one is finished: var enviarArquivo = function(indice) { Enviar($q, objetos[indice]).then(function() { if (++indice < objetos.length)…
-
2
votes1
answer98
viewsA: Return SQL data mysqli_fetch_assoc organized in a table
You have to print the data in the middle of your html: <table class="table table-hover" id="dev-table"> <thead> <tr> <th>ID</th> <th>Título da Questão</th>…
-
1
votes1
answer336
viewsA: JS event error to force and rename Download file
You’re making a mistake right now: evObj.initEvent(type, true, false); Because the variable type is not set. I tested by placing "click" hard code and it worked: evObj.initEvent("click", true,…
-
4
votes1
answer809
viewsA: Communication between pages via Javascript
One option I always suggest in such cases is the localStorage and that works in all most used browser. localStorage saves a DOM string where you can put not only strings but also objects using…
-
1
votes2
answers250
viewsA: Sum number of records per year and month
If I understand correctly you want a collection to count the accesses, right? var acessos = {}; _.each(visitYearGraphics, function (visitYearGraphic) { var key = visitYearGraphic.year + "." +…
-
5
votes2
answers449
viewsA: Putting Forward and Return Control on Slide Show
I made some simple adjustments for the slideshow to work only with the buttons next and Prev, and no longer with automatic transitions: $(function() { var $slideshow = $("#slideshow…
-
2
votes2
answers192
viewsA: Login PHP and Mysql generating mysqli_fetch_array() error
Try this: while ($row = mysqli_fetch_array($query)) The first parameter of mysqli_fetch_array() must be a resulttypeand not a string, which is the variable $user. In your logic, put everything that…
-
5
votes2
answers13570
viewsA: How to make a scroll to the end of a div?
Try to use the scrollHeight, which is a read-only property that measures the content of the element: var div = $('#div')[0]; div.scrollTop = div.scrollHeight; Source and Fiddle. Using only jQuery:…
-
5
votes1
answer1283
viewsA: Sum of Nodejs + Mongoose values
I believe you want something like this: var valor = 0; _.each(cliente.data, function (data) { valor+= Number(data.valor); }); You’re already iterating on cliente.data, would not need another…
-
1
votes6
answers14587
viewsA: Show the largest and smallest number
Why not ordain the numbers? function maiorDosTres() { var a = Array.prototype.sort.call(arguments); alert( "O maior número é: " + a[a.length - 1] + " e o menor é: " + a[0]); } Fiddle…
-
1
votes1
answer917
viewsA: How to set an initial date in this countdown done in Angularjs
What it seemed to me was that you always took the same starting date for the count, so the result of the counter did not change. So I created the parameter currDate, where the current counter date…
-
5
votes2
answers8159
viewsA: Type only letters and dots
See if this function works the way you need it: function somente_letras() { this.value = this.value.replace(/[^\w\.]|\d/g, ''); }; Where: document.getElementById("campo").onkeyup = somente_letras;…
javascriptanswered DontVoteMeDown 2,535 -
0
votes1
answer523
viewsA: How to do onkeypress function in dynamic field
Try this: input[cont].onkeypress = enter; Fiddle Or else with addEventListener: input[cont].addEventListener("keypress", enter); Fiddle…
-
3
votes1
answer66
viewsA: Block existing email in jquery.validate
Validator has a property called remote which may be used in your case: $( "#myform" ).validate({ rules: { email: { required: true, email: true, remote: { url: "check-email.php", type: "post", data:…
-
2
votes6
answers14101
viewsA: String Format with Javascript
Use this implementation: if (!String.prototype.format) { String.prototype.format = function() { var args = arguments; if (typeof args[0] != "object") { return this.replace(/{\d+}/g, function(m) {…
-
3
votes3
answers2918
viewsA: Format a string with time
You can use the method DateTime.Parse(): String.Format("{0:HH:MM:ss}", DateTime.Parse(dtSolicitacao)) Or else, in a more dirty way you can give a .Split() on date: IdentNomeHorario += " " +…
-
7
votes1
answer3472
viewsA: String comparison (which answers hours) in javascript is reliable? How does it work?
I think the best way is to turn the string into an object Date, I find it safer than comparing strings or manipulating them to do so. A very simple way is as follows:: // Verifica se hora1 é maior…
-
1
votes1
answer384
viewsA: How to reset form status with model data?
The reset() as explained in the documentation... The Htmlformelement.reset() method restores a form element’s default values should yes reset the value of the elements to the original state, and not…
-
0
votes1
answer237
viewsA: Select Kendo Grid row when clicking on the columns hyperlink
It’s actually not right to use the change in that case. The change It’s more like when the user clicks and selects the line. In this case, as the event relates to the specific column, it is not…
kendo-uianswered DontVoteMeDown 2,535 -
19
votes3
answers31270
viewsA: Format mask for CNPJ
To format at once, you can do it this way: "14397462000109".replace(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, "$1 $2 $3/$4-$5") Will result in 14 397 462/0001-09. Now, if you use an input mask in…
-
1
votes4
answers1283
viewsA: Alert message error
You have to count the query results within the loop: <?php $total_sucesso = 0; $total_erros = 0; for($i=1; $i<=$total; $i++) { // Insere os dados no banco de dados if…
-
5
votes3
answers298
viewsA: How to use Resources in . js file?
One way is you define these strings in its layout, for example in the tag <head>: <head> <script> var DISPLAY_OLA = "@Resources.DISPLAY_OLA"; </script> </head> But…
-
5
votes3
answers18470
viewsA: Is there any way to close a browser tab with javascript?
Use the window.close(). It closes the current window/tab. HTML: <input type="button" onclick="window.close()" value="Fechar janela" /> <button onclick="window.close()">Fechar…
-
1
votes1
answer153
viewsA: How to pick up only the images vertically?
You can compare the image dimensions, so if the width is less than the height, you can consider that the image is vertical, right? Example: var imgs = document.getElementsByTagName("img"); for (var…
javascriptanswered DontVoteMeDown 2,535 -
2
votes2
answers4212
viewsA: Prevent the action of reloading the page by clicking on the OK of ALERT JS
The @Ivanteles response is correct and in my opinion it should be used, but only for information purposes: $('#btnCadMed').click(function(e) { if(nome == "" || CRM == "" || idt == "" || esp == ""){…
-
3
votes2
answers4299
viewsA: Picking attributes from an object using jQuery
For debug purposes (which seems to be your case) use the console.log(): success: function (data) { console.log(data); }, To access the properties of an object, use Object.keys(): success: function…
-
3
votes3
answers6399
viewsA: How to zoom in on an image by hovering over it?
It is possible to do without using Javascript, which I find more cool. Using the property transform:scale of CSS3: img { -webkit-transition: all 1s ease; /* Safari and Chrome */ -moz-transition: all…
-
4
votes2
answers245
viewsA: How to receive a title(title) from an image to the value of a variable?
This happens because the method getElementsByTagName() returns a collection of DOM elements. You have to access, in this collection, the desired element and then its attribute title: // Por ex,…
javascriptanswered DontVoteMeDown 2,535 -
0
votes2
answers102
viewsA: Position all selects at index 0 with Jquery
In his job clearModal(), add the following line: j$('#modal-edit-veiculo .modal-body select').prop('selectedIndex', 0); Thus remaining: function clearModal() { j$('#modal-edit-veiculo .modal-body…
-
9
votes3
answers260
viewsA: Create a real "loading..."?
It actually works like this: The ajax request has events, one of them is the conclusion, success in the case of jQuery. Then the process becomes simple. You showcase the image when opening the…
-
2
votes3
answers178
viewsA: Effect of filling in a line
Looking at the source, more precisely the file myscript.js it is possible to see that the plugin is used Easy Pie Chart, which is called upon the elements .chart by means of the following script:…
-
1
votes2
answers3665
viewsA: Variable global angular problem
This happens because the $http executes an asynchronous request, then the resultado the moment you loga it has not been filled in yet. It will only be filled in after the request is finished and in…