Posts by Miguel • 29,306 points
758 posts
-
2
votes1
answer353
viewsA: PHP function always returning NULL
Missing a Re-turn on else too. Try it this way: function merge($correto, $incremento, $parada){ $atual=$correto[$incremento]; $anterior=$correto[$incremento-1];…
-
4
votes1
answer158
viewsA: Simple doubt about for loop
I believe you are not looking for a loop, but rather for a setInterval: $('.item:gt(0)').hide(); // esconder todos os items cujo index é maior que 0, só o primeiro fica visível var countItems =…
-
1
votes1
answer699
viewsA: Validate field with ajax and php
Add a return false, if it is not valid, and return true if valid: function valida_nome(){ var filter_nome = /^([a-zA-Zà-úÀ-Ú0-9]|\s)+$/ ;…
-
1
votes1
answer89
viewsA: Transmit information between html pages with jQuery?
@Joao Souza can do with hash, so do not operate with cookies for this: <ul id="resultado-pesquisa"> <li class="itens-pesquisa"><a id="0101" href="detalhes.html#0101">Clicar para…
-
2
votes2
answers875
viewsA: Concatenating Javascript Object
Must use push to add elements to an array and it is not worth always initializing the variable within the cycle: var donutData = []; for(var k in lista) { for(var x in lista[k]){…
-
1
votes2
answers10158
viewsA: How can I center my form within my div?
The default form has a width of 100% of the parent element. You have to set text-align:center form { text-align:center; border: 1px solid; } <div> <form action="search.php" method="GET"…
-
1
votes1
answer1016
viewsA: Input type file with pre-selected image
Set this directly on ..input type="file".. can’t. You can do it in text: <input type="file" id="imagem" name="imagem"> <span><?php echo $imagem_da_BD; ?></span> You can also…
-
1
votes2
answers151
viewsA: Help to create an image loop with $_SESSION
Can do: <?php session_start(); // isto tem de estar antes de tudo na página, no topo ... $_SESSION['banners'] = array(); while($res = mysql_fetch_array($query)){ $_SESSION['banners'][] =…
-
0
votes1
answer94
viewsA: How can I use this code?
You can in the terminal do: python ficheiro.py www.google.com 123 I’m warning you right now, it’s not gonna do what you expect, there’s not gonna be any... You should know that you shouldn’t try…
-
2
votes2
answers966
viewsA: Hide a div when showing another
You can do it like this: <div class="conteudo_cima" id="<?php echo $id2; ?>"> <img id="trigger_expand" data-show="<?php echo $id2; ?>" src="imagens/encolher.png"> Then it…
-
2
votes2
answers162
views -
2
votes3
answers804
viewsA: How to know if the database query was successfully performed?
Though I don’t recommend that way, you should use Prepared statments, but the error is that you are not actually using the variable that contains the value of $_GET['q']. You have to insert into the…
-
3
votes1
answer1502
viewsA: Check if there is a file if there is a report of PYTHON Blibioteca > . os
The problem is you’re trying to create the directory right on this line: os.mkdir (input('Insira o nome:')) And it launches the exception (this warning/error), because it should already exist. You…
-
2
votes1
answer225
viewsA: Delegation of events to dynamically generated elements
Delegates the event to the parent element, to an element where the event can be associated with the page load. Instead of delegating to the specific element that does not yet exist. To delegate…
-
5
votes1
answer1118
viewsA: Discover common elements in multiple lists
You can use sets and intersect them, sets are commonly used to prohibit duplicate values in a list, if you want to remove repeated values turn your list into a set (set(minha_lista)). But for in…
-
2
votes1
answer1566
viewsA: Node.js does not load js or css scripts
You have to set up in your server.js a base directory so that html can make use of resources. Put this next to var users = [] and see if it works: app.use(express.static(__dirname + '/'));…
-
2
votes1
answer162
viewsA: How to Loop $_SESSION
Yes of course you can: <?php session_start(); .... $_SESSION['banners'][] = 'imagem1.jpg'; $_SESSION['banners'][] = 'imagem2.jpg'; $_SESSION['banners'][] = 'imagem3.jpg'; ... The value of…
-
1
votes1
answer160
viewsA: cannot get/ chat socket.io
I think it is missing which service (URL) will perform a certain function, and when access send the file you want to see in the browser: That is to say: ... var users = []; app.get('/',…
-
1
votes2
answers467
viewsA: How to multiply one variable by another
Will be this who wants: <script> function calcular() { var valor1 = parseInt(document.getElementById('bikemountain').value); var valor2 =…
javascriptanswered Miguel 29,306 -
2
votes2
answers44
viewsA: Automatic redirection of pages
You can do this with HTML meta tag, insert them into <head>: With a time interval of 10 secs in each, in your case: From painel1.php to painel2.php, enter the following meta tag in…
-
1
votes1
answer271
viewsA: Document.getElementsByClassName("x"). innerText is not working
document.getElementsByClassName(...) returns an array (array) of all elements with the class. Do so: document.getElementsByClassName("life")[0].innerText = "outrovalor" So we select only the first,…
-
8
votes1
answer2861
viewsA: Extract name and last mysql surname
If you want to extract right from the database with SQL: SELECT SUBSTRING_INDEX(coluna_nome, ' ', 1) as nome, SUBSTRING_INDEX(coluna_nome, ' ', -1) as sobrenome from tabela_pessoas; But from what…
-
1
votes1
answer130
viewsA: Login PHP if Admin
The best thing for this is to add either an admins table (that would be what I would do) or add a column in tb_utilizador with the name ex: is_admin, which can take two values for each line, "1" (is…
-
3
votes2
answers281
viewsA: Function Empty returns true (truth) when value is 0
I’ve been running some tests and taking this under consideration: I have come to the conclusion that the whole value 0 and the string "0" are considered empty for the method empty(), returns true.…
-
4
votes1
answer728
viewsA: Dictionary, separate values and keys into two lists
This solution I will give you works on both python 2.7.x and python 3.x. x. To separate abc = {'y': 'Y', 'b': 'B', 'e': 'E', 'x': 'X', 'v': 'V', 't': 'T', 'f': 'F', 'w': 'W', 'g': 'G', 'o': 'O',…
-
0
votes4
answers2082
viewsA: Keep Ivs side by side even if the line runs out
Here’s a way of doing that. The trick is to have three levels, the middle one being, div_3 in this case, it must be longer (width) that its parent element div_1 this has to stay with overflow-x:…
-
1
votes2
answers190
viewsA: Javascript validation is not working
The function is not being called because there is a conflict enter button id (validar) and the name of the function, which is also validar: Change the button id to something else. I adjusted the…
-
0
votes1
answer62
viewsA: Open page in a particular section
"...or that was already carried in it what would be better...". For this need not use jQuery, since the browser (browser) does it for us, trick is to insert the id section of the page you want to…
-
2
votes1
answer3702
viewsA: Laravel - validate input arrays and return values in case of error
I’ve been testing and from what I think I’m doing this way it’s because you’re using Laravel 5.2, because the previous ones didn’t have validation built-in for inputs in array then did: LARAVEL 5.2:…
-
1
votes2
answers96
viewsA: Regex works on online tester but does not work on my javascript site
Remove the quotes. Try the following: var string = "12.0,34.0"; var re = new RegExp(/[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+))?/); if (re.test(string)) {…
-
1
votes1
answer47
viewsA: this giving error Parse error: syntax error, Unexpected $end in /home/Kleber/public_html/adds-product.php on line 24
It’s boring but you have to open php tags to close the braces ... ?> <p class="alert-success"> produto <?php echo $nome ?> adicionado com sucesso! Preco <?php echo $preco…
-
0
votes3
answers115
viewsA: Multidimensional array
We have to create 6 matching test lists within a parent list': test = [290,293,291,294] final = [[i for i in test] for i in range(6)] print(final) # [[290, 293, 291, 294], [290, 293, 291, 294],…
-
4
votes2
answers3681
viewsA: How do I get JSON from a URL to use in my PHP file?
With: file_get_contents('http://api.promasters.net.br/cotacao/v1/valores?moedas=USD&alt=json'); Can’t, because that url is blocking by user_agent but we can fake it. Try so: function…
-
2
votes2
answers63
viewsA: Error adding elements in Mysql Database with PDO
Has a little syntax: it must be so: $stmt = $conn->prepare("INSERT INTO usuarios (nome, idade) VALUES (:nome, :idade)"); $stmt->bindParam(":nome", $_POST["nome"]);…
-
6
votes2
answers859
viewsA: Invert array (vector) without an external function, 'manually'
The trick is in building the cycle for, must count from the end to the beginning of the array (vector) #include <stdio.h> int main() { int original[] = {1,2,3,4,5,6}; int count =…
-
2
votes3
answers4851
viewsA: Cut string at last occurrence of a character in a string
You can create this function: CREATE FUNCTION SPLIT_STR( x VARCHAR(255), delim VARCHAR(12), pos INT ) RETURNS VARCHAR(255) RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),…
-
2
votes1
answer62
viewsA: Center element with bootstrap
The problem is on this line: <div class="col-md-5" style="margin: 20px"> To center using only bootstrap use offset col-X-offset-Y. Change to: <div class="col-sm-4 col-sm-offset-4"…
bootstrap-3answered Miguel 29,306 -
4
votes2
answers239
viewsA: Multiple assignment in Mysql
Facing the problem customers/phones the best way is to create a table with telefones since it is a relationship of many to one (1:N) a customer for many phones. That is to say: clientes id | name |…
-
1
votes1
answer480
viewsA: Python lists and dictionaries
From what I understand it might be this, see if it helps count = 0; for i in range(0, len(a)): for j in range(0,a[i]): if a[j]==1: print ("no%d. G1 = %f \n" %(sub_ind_novo[i],Lista[count])) else:…
-
0
votes2
answers579
views -
7
votes2
answers1356
viewsA: Convert a list list into a single list
To make a single list of: Resultado=[['A','B','C'],['D','E','F'],['G','H','I']] Do (no need to import external libs for this, this is what I recommend): Lista = [item for sublista in Resultado for…
-
1
votes2
answers48
viewsA: get combo field values before saving
When you press the button to display the choices you will have to scroll through the elements to see what the value (choice) is in each one: $('#check').on('click', function() { var escolhas =…
-
6
votes1
answer3233
viewsA: Change content by clicking icon and changing icon
From your jsfiddle I see you use jQuery. Do so: $('a').click(function() { $(this).find('i').toggleClass('fa-minus-circle fa-plus-circle'); $('.content').toggleClass('active'); }); .content.active {…
javascriptanswered Miguel 29,306 -
1
votes1
answer263
viewsQ: innerHTML only takes effect once, and dynamically generated elements
I am doing a javascript experiment that when clicking on a certain element with a certain class we will add a new element with the same class, whenever clicking should appear a new element. var…
-
1
votes2
answers225
viewsA: Make a hidden form
Has here an example of how to show/Hide to the form: // carregar no botão para editar e o form aparece var btn_editar = document.getElementById('btn_editar'); btn_editar.addEventListener('click',…
-
2
votes2
answers1774
viewsA: Capture values after an input checkbox
In the onchange you should walk all <inputs type="checkbox"> that are checked and increase its value in total. EXAMPLE $('input[type="checkbox"]').on('change', function() { var total = 0; var…
-
3
votes1
answer100
viewsA: How do I define custom sorting on the return of a DB?
To do this you have to store the custom order you want. You can create a column in your table with the order (int), and then sort from there with the SELECT * FROM produtos ORDER BY ordem ASC/DESC…
-
2
votes2
answers972
viewsA: Why only use Return, without returning any data?
It is possible. For example the print function is a function that returns nothing, it will only perform the print (equivalent to include in your example) and finish.
-
4
votes1
answer71
viewsA: Increment opacity of an element
The problem is that the opacity value is interpreted as a string (text), not as a number. You can do thus: function fadeIn(elem, speed) { if(!elem.style.opacity) { elem.style.opacity = 0; } timer =…
javascriptanswered Miguel 29,306 -
1
votes2
answers5091
viewsA: How to make a simple and responsive horizontal menu?
Although I have not posted your HTML and we do not know what is what I understood the problem and I believe I can adjust this to your case: The trick in this case is to play with the length relative…