Questions tagged as 'javascript'

2
answers

Execute statement only if 5 conditions are true. Javascript

What command should I use to execute a statement only if 5 conditions are true? For example In Portuguese: Se 1 +1 = 2 e 2 +2= 4 e 4 +4= 8 e 5 +5= 10 e 6 +6= 12 então faz isso. How do I do this in javascri...
asked by 02.06.2016 / 06:15
3
answers

Problem when ordering an array with sort ()

One of these occurs when I want to sort an array of numbers. Ex: var a = [44,7,5,6,4,2,1]; a.sort(); console.log(a); The expected result would be: [1, 2, 4, 5, 6, 7, 44], but what is always returned to me is [1, 2, 4, 44, 5, 6, 7]....
asked by 16.03.2016 / 15:36
3
answers

Return in hours the difference between two dates in JAVASCRIPT

I've just seen this question here in Stack Overflow that shows how to solve my problem but in PHP. I would like to know how I can calculate the difference between 2 dates and show this in hours. ex: var d1 = new Date('2015-12-21 00:00:00').t...
asked by 21.12.2015 / 14:04
3
answers

Why does it always return null?

I created this FIDDLE as a test. I have this li inside a variable and I want to add the class c2 to that same li var linha = '<li id= "id1" class="c1"> ' + '<div id="id2">1</div>' +...
asked by 17.06.2015 / 13:11
6
answers

Calculate the rest of a division of decimal numbers in JavaScript

I'm working with values ( decimal(18,2) ) of a sale where the sum of the price of the products should turn into a certain number of parcels. So that I can divide the total of the products exactly for the parcels, I also have to calculate t...
asked by 08.01.2016 / 14:08
3
answers

How to check if Ajax's return is JSON or String?

My code looks like this: sendAjax(new FormData(this), function(retorno) { if(retorno.isArray) { $(".erro-login strong").text("ID: " + retorno.id + " usuário: " + retorno.usuario); $(".erro-login").show("slow");...
asked by 17.05.2016 / 20:44
3
answers

How to not allow repeated INSERT giving reload on the page? [duplicate]

How can I do not to allow% re_completed if someone reloads the page? Example: $libera = $_POST['libera']; if ($libera == "sim"){ $sql = mysql_query ("INSERT INTO a_finan(id_reserva,id_cliente)VALUES('$id_res','$id_cliente')", $conexa...
asked by 16.01.2016 / 16:49
2
answers

How to make a tutorial of first access to the site?

I would like to create a First Access Tutorial for my Site , those that show what each field in the site means, need a hint how to do it or if there is any Framework for this type of interaction with the user, I did some research and did not fi...
asked by 08.03.2016 / 16:36
4
answers

How to make a LOOP run according to the return of a Promise?

How can I make my loop wait for the return of a promise? Let's say I have the following code: for (var i = 0; i < 10; i ++) { // algumalógica fazAlgumaCoisa(array[i]); } var fazAlgumaCoisa = function(obj) { $http.get(url).then(...
asked by 29.06.2016 / 14:51
4
answers

Compare current date with javascript

I'm comparing today's date with today's date like this: if (new Date() > new Date('07/04/2017')) { alert('Hoje é maior que hoje?') } How can today be greater than today?     
asked by 04.07.2017 / 17:51