Posts by Pedro Camara Junior • 6,637 points
151 posts
-
5
votes4
answers181
viewsA: Unidentified error in Jquery
Instead of doing the append within the loop, do this only once after finishing the loop. var html = ""; $(retorno).each(function(key, value) { html += "<div class='col-lg-3 col-sm-3 col-md-3…
jqueryanswered Pedro Camara Junior 6,637 -
4
votes1
answer3632
viewsA: How to know which jquery version was loaded
Use the command $.fn.jquery to get a string with the version. Note in the example, that the version that will be loaded in the project will always be the last, will never be loaded more than one…
jqueryanswered Pedro Camara Junior 6,637 -
1
votes3
answers325
viewsA: Multiply line
You will need to use a loop to go through all the elements and get the value of each and multiply them. var blocos = $("table tr").find("td"); var total = 1; blocos.each(function (index, element) {…
-
3
votes2
answers237
viewsA: How do I select only one element with a class that exists in other elements?
Use the selector switch eq(Index) jQuery to select an element by its content. var $elemento = $('.imagem:eq(1)'); See the example below manipulating the element. var $elemento = $('.imagem:eq(1)');…
jqueryanswered Pedro Camara Junior 6,637 -
3
votes1
answer293
viewsA: Problem with auto Focus
You are using the event blur that is invoked or invokes focus loss. To assign the focus use the event focus. There are two ways you can call the event, can be using the trigger('focus') or only…
jqueryanswered Pedro Camara Junior 6,637 -
1
votes2
answers901
viewsA: Colorize Selected Line Angular JS and Bootstrap
If your intention is to mark and uncheck, one option is to create a variable boleana which will be "on" or "off" when clicking. .azul { color: blue; } <script…
-
0
votes3
answers149
viewsA: How to delete a DIV if there is a word in another DIV in jQuery?
An alternative to become more configurable is to use regular expressions. In the example the REGEX.test() will return true if it contains the word Oversound or JBL and then you’ll get the treatment…
-
2
votes1
answer469
viewsA: Send id to an Hidden field by clicking on an item in the.js autocomplete
Use the function select, it is called every time a menu item is selected. $('#clientes').autocomplete({ select: function(event, ui) { $('#clienteId').val(ui.item.id); console.log('Objeto…
-
3
votes2
answers3023
viewsA: How to lock certain keys in an input using Javascript?
Because AP needs to use positive values or negative, I edited the answer suggesting the plugin Mask money instead of jQuery Mask - https://github.com/igorescobar/jQuery-Mask-Plugin Mask money Use…
-
16
votes3
answers40219
viewsQ: How to format a date in 'dd/MM/yyyy' format?
How to get a formatted string from an object of type Date in format dd/MM/yyyy?
-
20
votes3
answers40219
viewsA: How to format a date in 'dd/MM/yyyy' format?
Use the Angularjs filters To format dates in Angular, there is the Angular Filter which is very useful and easy to use, whether in the view or us controllers. The filter can still be used to format…
-
1
votes1
answer3920
viewsA: 1 decimal formatted value in ngModel
EDITED: As AP edit, I created a directive that formats the value as needed. I put two options, using the toFixed() of JavaScript or the $filter of Angular. Use the filter number.…
angularjsanswered Pedro Camara Junior 6,637 -
2
votes2
answers1474
viewsA: How to change the color of a tr according to the data of a td?
See the example using the function find() Tip: Instead of using the innerHTML javascript, please use the html() jQuery, you may experience problems in some browsers using the innerHTML already the…
-
5
votes5
answers10211
viewsA: Spacing between Bootstrap inputs
Use the classes themselves bootstrap to do this, in this case, leave the form items inside a div with the class form-group <link…
-
2
votes1
answer368
viewsA: Fill textfield with the description corresponding to the value selected in a combobox
Assign the description in your options Since you are already using the value and text of the option, you can create an additional attribute in option. Behold date-* @foreach($mfuncoes as $mfuncao)…
-
1
votes1
answer410
viewsA: checkbox "select all" jquery and Cakephp
First, you must have something to identify the checkbox which will be selected, may be a common class, may be within a div or any other block. Assign the event change at the checkbox who will be…
-
3
votes3
answers1304
viewsA: Download HTML link from the bank
First you must use a hyperlink tag <a> and using Javascript you will add the URL to the attribute href using the function setAttribute. Take the example: var $meuLink =…
-
7
votes3
answers61753
viewsA: Remove a specific element from the javascript array
You can use the method Slice. The parameters are the initial index and the final index you want The method returns a new array with the selected elements The selected elements will be those that are…
javascriptanswered Pedro Camara Junior 6,637 -
-1
votes4
answers15818
viewsA: Add and Subtract value from same SQL column
The error is shown to you because when you remove the filter (Cod_art = '11430001') your query returns more than one record, and not it is possible to subtract the amount. See the changes that made…
-
11
votes3
answers147
viewsA: How to put Html snippet on all child elements except the last one?
Use the operator .not() combined with the selector :last-Child $("#id").children().not(":last-child").html("<input type='text' value='" + valor + "' />");…
-
4
votes2
answers7334
viewsA: How to redirect page in Angular?
I would use the $Location to redirect. app.controller('myController', function($location) { // ... // $location.path('/path'); });…
-
4
votes2
answers69
viewsA: Filling of two equal inputs
You should assign an event to txt that will be used to type. See the example I did using keyup. $('#txtUm').on('keyup', function () { $('#txtDois').val($(this).val()); }); <script…
-
1
votes2
answers1751
viewsA: Like counter with JS/Jquery?
At the event click use the this to get only the element that was clicked. To manipulate the item below, in case the li with class like use the next. The way you did $(".like") was manipulating the…
jqueryanswered Pedro Camara Junior 6,637 -
1
votes3
answers2215
viewsA: Nodejs NPM does not work
You are just executing in the wrong place your command. The npm is the Node Package Manager, you do not need to "start" the node (Node + enter on your console) to use it. Open the command and type…
-
2
votes2
answers1328
viewsA: Calling javascript function with null parameter
You can call a function with missing parameters without any problem, including it is a practice (as far as I know) for optional parameters, the only thing you should do to avoid errors, is to check…
-
4
votes3
answers1573
viewsA: Avoiding line breaks in text areas
You can do this using javascript, just manipulate the event onkeypress of textarea, check if the key pressed is the enter and perform form Submit or anything else you wish.…
-
2
votes4
answers877
viewsA: How to search for an element with the same class depending on the number of children?
One way is by using the jQuery.filter() var $elementos = $(".teste"); var $minhaUl = $elementos.filter(function() { return $(this).find('li').length === 1; }); $minhaUl.css('background', 'blue');…
-
3
votes1
answer1983
viewsA: Get column values from a table and save the value of each column in an input
In your case use the Parent to select the tr father of tdthat was clicked, after accessing the tr use the function find to select the td's daughters and use selector :Nth-Child() to select each…
-
1
votes3
answers650
viewsA: Jquery calculate average and insert the result into the average field that is disable
Using the same logic shown in your code, one solution is to check if any input is empty and exits the function using Return. See this example. $('input').on('change', function() { var $txtValor1 =…
jqueryanswered Pedro Camara Junior 6,637 -
14
votes1
answer13196
viewsA: Hide field in HTML with Bootstrap
Use the Bootstrap responsiveness classes http://getbootstrap.com/css/#Responsive-Utilities-classes In your case, use the classes hidden-xs to hide something in mobile resolution and visible-xs to…
-
0
votes6
answers49720
viewsA: Convert DATA dd/mm/yyyy hh:mm:ss to yyyy/mm/dd
EDITED: After some tests performed I observed that the function CONVERT will only work if the variable that will be formatted/converted is of the type Date. Use the function…
-
2
votes1
answer41
viewsA: how to make a Join Inner picking up the description
You just need to give a "nickname" to your tables SELECT ag.id as id_agencia, ag.nome as agencia_nome, ad.id as id_ads, ad.agencia as ads_agencia_id FROM agencias ag INNER JOIN ads ad ON ad.id =…
-
2
votes2
answers229
viewsA: Create javascript-mounted title attribute in <td>
I did not understand this line: 'tr td:Nth-Child(15)' The selector Nth-Child() allows you to select the child element of a parent element, either by the index, by the child element class or by a…
-
2
votes1
answer2361
viewsA: How to put mask on table with angular?
Use the filter currency To show in real format (R$) you have two options, using the Angular Locale, see Using Locale in Angularjs <!--Utilizando o Angular Locale--> <script…
-
3
votes1
answer73
viewsA: Group by with subdivisions
To get the total amount of men and women, make a sub-select for each and group by date. SELECT COUNT(*) AS 'quantidade', F.data_nasc, ( SELECT COUNT(*) FROM formandos AS H WHERE H.genero = 'M' AND…
-
1
votes1
answer38
viewsA: How to ask the reason for a deletion using confirm and prompt?
You can use the function prompt javascript console.log(mostrarPrompt()); function mostrarPrompt() { var motivo = prompt('Informe o motivo'); if (motivo === '') mostrarPrompt(); if (motivo !== null)…
-
12
votes3
answers7644
viewsQ: How to create a Datetime object that represents the last day of a given month?
On an object of the type DateTime, how do I get a new object object DateTime representing the last day of the month of the first object? var data = new Date(2017, 3, 1); // 01/03/2017 var…
-
10
votes3
answers7644
viewsA: How to create a Datetime object that represents the last day of a given month?
I found that answer in Soen To get only the day there is the method Daysinmonth which receives as parameters the month and the year and will return a int that will be the last day. With the last day…
-
10
votes4
answers1023
viewsA: Send more than one parameter in GET request
Another way is to send an object as "second parameter", according to the jQuery.load documentation(). var parametros = { estado: $('#estados').val(), recurso: $('#recurso').val() };…
-
1
votes1
answer56
viewsA: Catch Total value except date
To find a date period use the operator BETWEEN and to exclude some dates use the operator NOT IN. How you are using the function SUM you need to use the grouper GROUP BY at your request. SELECT…
sqlanswered Pedro Camara Junior 6,637 -
3
votes5
answers6529
viewsA: How to create buttons to increase/decrease font?
As I saw that you are using jQuery in your code I made an example: You can get the font size of the element you want, class or whatever, and at the click of the button increase or decrease the font.…
-
1
votes2
answers547
viewsA: Force CSS in IE
You can have two style sheets and use one for IE and others for other browsers. <!--[if IE]> <link href="somente_ie.css" rel="stylesheet" type="text/css"> <![endif]--> <!--[if…
-
9
votes5
answers8511
viewsQ: Reverse array order
I have the array: var meuArray = [1, 2, 5, 7, 9, 4]; How to reverse the order so it stays the following way: [4, 9, 7, 5, 2, 1]
javascriptasked Pedro Camara Junior 6,637 -
3
votes5
answers8511
viewsA: Reverse array order
A way I found and using the re-verse var meuArray = [1, 2, 5, 7, 9, 4]; var meuArrayInvertido = meuArray.reverse(); //meuArrayInvertido === [4, 9, 7, 5, 2, 1]…
javascriptanswered Pedro Camara Junior 6,637 -
1
votes4
answers16240
viewsA: HTML -Spacing between tds
You can use the property css border-Spacing in his table. table { border-spacing: 15px 10px; } table>tbody>tr>td { background: blue; padding: 5px 20px; } <table> <tr>…
-
7
votes9
answers34793
viewsA: Input type="password" with password display eye
I made an example using the bootstrap to create the eye and the script used is basically the same used in the other answers. var $spnMostrarSenha = $('#spnMostrarSenha'); var $txtSenha =…
-
1
votes1
answer2028
viewsA: Display message for form validation instead of alert
One option is to create a div right after the txt or in a place of your choice, and in that div you will do the innerHTML from the validation message, I made an example for you to see how it works:…
javascriptanswered Pedro Camara Junior 6,637 -
2
votes1
answer112
viewsA: How to add groups of inputs according to the number inserted in a text box without refreshing
Using jQuery you can make a loop for and create as many inputs as you need. See an example: $(document).ready(function() { var $txtQuantidade = $('#txtQuantidade'); var $btnAdicionar =…
-
12
votes5
answers23670
viewsA: How to make Javascript calculations accepting comma to separate decimal places
Use the following Javascript methods replace to exchange the comma for a point parseFloat to convert to float/double toFixed to define how many decimal places you want after the comma var string1 =…
javascriptanswered Pedro Camara Junior 6,637 -
0
votes3
answers504
viewsA: Disable input text by clicking another input text
To do exactly what you asked just add the attribute disabled at the txt the moment you click the other one. However, this is a little strange, because the moment I select a txt I can no longer…