Posts by Miguel • 29,306 points
758 posts
-
1
votes1
answer235
viewsA: Distance count between one element and each other in a list (Python)
The best way to store the data is by using a dictionary. You can do so: distancias = {} lenLT = len(linha_tempo) for i in range(0, lenLT): if(linha_tempo[i] != 0 and linha_tempo[i] !=…
-
3
votes1
answer77
viewsQ: How to get parent elements except for some in native Js
Let’s say I have: <section id="ele-section1"> <div data-section="1"> <div class="not_this"> <div> <div class="ele2"> <div id="ele3"> <div class="ele4">…
javascriptasked Miguel 29,306 -
1
votes1
answer171
viewsA: How to check variable only with javascript spaces?
Taking advantage of the code you have and using Trim(), serves to remove end/start spaces from a string: $('#msg').on('keyup',function() { var textarea_value = $("#msg").val().trim();…
javascriptanswered Miguel 29,306 -
10
votes2
answers1563
viewsA: How to get all parent elements except for a few
With the function parents() is simple, just put inside the function not() those elements you don’t want: var pais = $('.4').parents().not('.all, body, html'); pais.each(function() {…
-
2
votes2
answers241
viewsA: Ordering of all elements of a multidimensional array (array)
With ksort: Tested array: $array = array( 'AM' => array( 2 => array( 'localidade' => '1Arena da Amazonia', 'cidade' => 'MANAUS', 'estado' => 'Amazonia', 'acronym' => 'AM', ), 1…
-
4
votes1
answer165
viewsA: python process
A little more complex than you might think at first. This (Sharing state between processes) when it is with integers it is a little simpler than with strings. EX with integers: from multiprocessing…
-
4
votes2
answers1094
viewsA: How to return the page with the "Chor" of the LARAVEL id?
Concatenating to the previous url is enough : $urlBack = redirect()->back()->getTargetUrl(); return redirect($urlBack. '#menu1'); Tested in Laravel 5.1 and 5.2 Version 5.3 and 5.4 we can do…
-
2
votes2
answers674
viewsA: Validating input file with ajax request
@If Sergio has not changed anything in the code however, do this, step by step, should not fail anything: When files are mixed we should use Formdata() to send data + files to server when we upload…
-
1
votes2
answers1182
viewsA: Upload Json to Google Maps
That’s what I told you to put the map initiation call on the success of ajax, and also pay attention when calling the library, in this example I used <script type="text/javascript"…
-
9
votes3
answers37709
viewsA: Remove element from a list by key (key) and by value (value)
my_list = [1,2,3,4,5,6,7,8,9] val_remove = 7 Remove by value my_list.remove(val_remove) Take into account that in this way: Only removes the first occurrence of the element if there are two or more…
-
1
votes1
answer50
viewsA: javascript does not return when concatenating link
Adjust only the id in html (onclick=...) for '<?=$user_id;?>'. I think this is what you want <div id="link-bt"> <a href="javascript:void(0);" onClick="seguir('link-bt','Seguir', 5);"…
-
5
votes1
answer212
viewsA: Showing validation errors in the contact form
The problem is in the conditions, as they are wrapped in else if(... from the moment you enter one you will no longer enter the next, even if it is true. Do so: $erro = array(); if (empty($nome)) {…
-
1
votes1
answer4497
viewsA: fill input with select value in jquery
If I understand correctly, this is what you want: $('.plan').on('change', function() { var plan = $(this).val(); $('#valor').val(plan); }); <script…
-
2
votes2
answers453
viewsA: Change the home page via htaccess
Your htaccess must be in root (public_html, I believe). Try this in your . htaccess: DirectoryIndex Login.php
-
3
votes1
answer881
viewsA: Nested Functions in Python
@Allan here goes. The problem is that when we are accessing properties/methods within the class we have to use the prefix/argument self that is to say that the method/property belongs to that class.…
-
3
votes1
answer1956
viewsA: While timer in Python
You can do it like this: import time end_time = time.time() + 10 countTimer = 0 sleepTime = 0.500 while time.time() < end_time: time.sleep(sleepTime) countTimer += sleepTime print('hello, ja…
-
2
votes2
answers1609
viewsA: Random distribution in lists with python
Exactly with Choice can do, should import module Random: import random cs = [2313, 2214, 2120] gav = [1101, 1103, 1104] icc = [3201, 3304, 3209] comp = [4101, 4203, 4409, 4559] disciplinas = [cs,…
-
1
votes1
answer206
viewsA: Check current index and next index equal to zero python
You can do it like this: l = [0, 0, 2313, 1221, 0, 1333, 66, 0, 0, 0, 0] lCount = len(l) next1 = False for i in range(0, lCount-1): if(l[i] == 0 and l[i+1] == 0): l[i] = 1 next1 = True elif(next1):…
-
1
votes2
answers78
viewsA: "Permissive" regular expression to detect extensions and allowed hosts
We have then: urls = ["https://www.exemplo.com/", "https://www.exemplo.com/home/", "https://www.exemplo.com/logo.png", "https://intranet.exemplo.com/", "https://admin.exemplo.com/login",…
-
2
votes1
answer65
viewsA: Graphs in JS , error when entering BD data
You can do it like this: $labelsJS = array(); $valsJS = array(); while($row=$graph->fetch_assoc() and $i<=$graph->num_rows){ $data=date('M',strtotime($row['data'])); ?> row[0][<?php…
-
0
votes2
answers597
viewsQ: Many to many ratio between various tables
I know that between two tables in a ratio of many to many 'we need' (not mandatory, but facilitates) a third table pivot which is what conventionally relates the ids of one with the ids of the…
-
3
votes1
answer169
viewsA: How to avoid confusion of querys executed at the same time with Php and Mysql?
It is very important that you store the connection in a variable so that you don’t always connect. I don’t know how you have your connection but try this way: .... $conn = Conexao::conectar();…
-
0
votes1
answer171
viewsA: Control employee point card
I think this is what you want, the array $batidas will store this information per day: <table class="table table-striped"> <tr> <th>Data</th> <th>Dia Semana</th>…
-
3
votes2
answers361
views -
0
votes1
answer104
viewsA: Links in php tables
Taking advantage of the code that you have, which I believe works, we will add Anchors (href): if ($result->num_rows > 0) { echo "<table style='width:100%' height='100%'> <tr>…
-
0
votes1
answer62
viewsA: convert content into input
Create an event executed on all inputs except the one whose name is nao_alterar. Do: $('input').not('[name="nao_alterar"]').on('input', function() { // Armazena posição corrente do cursor var start…
-
0
votes2
answers305
viewsA: Vector make a mysql query
Try it like this: ... $query = "select * from produtos where"; foreach($produtos as $prod) { $query .= " descricao='$prod' OR"; } $query = rtrim($query, ' OR'); $x = mysqli_query($conn, $query);…
-
1
votes1
answer166
viewsA: Change page in same php file
This can’t be done with php. You can do it with javascript, though. That is, all the contents on a single page, and each link makes some content disappear and others appear: For this example I will…
-
5
votes2
answers453
viewsA: How to remove some data from a JSON and display only the rest?
Look do so, there was a problem in the Character encoding, we have to do utf8_encoding: <?php $jsonRaw = file_get_contents('http://hts03.kshost.com.br:8642/statistics?json=1'); $jsonParsed =…
-
4
votes1
answer2270
viewsA: Hide part of a text with javascript
Take advantage of date attributes to make your life easier, in this case the button to show more data-mais will have the full text and button to show less data-menos will have the text limited,…
-
5
votes1
answer328
viewsA: block upload greater than 2mb with PHP
Each $_FILES key/file pussui a key size, that by default comes measured in bytes. We can convert like this for 2mb: if($_FILES['imagem']['size'] > 2097152) { echo 'não é permitido'; } To 2gb:…
-
0
votes2
answers77
viewsA: mai() php function not working under conditions
You must have to define some headers (not default ones) to 'trick' some email clients who might think it is spam, namely the From and the Reply-To, Set your headers like this: $subject = 'Ajudar…
-
4
votes1
answer233
viewsA: How to group dates from an array?
Can make each month/year a key of the new array: <?php $datas = array( '2016-09-25', '2016-09-08', '2016-10-11', '2016-10-05', '2016-11-19', '2016-11-05', '2016-09-07', ); $novasDatas = array();…
-
2
votes2
answers137
viewsA: Number of entries in SQL PHP
No use doing it twice mysql_query. Do: include("Config.php"); $rows = mysql_query("SELECT * FROM tb_utilizador") or die('Problema na query'); $num_rows = mysql_num_rows($rows); // isto vai dar o…
-
0
votes2
answers256
viewsA: Insert Into Array Problem
I’m not sure how your classes are structured, but I have an idea of the program you’re doing. I made a small example that I think I can give you some light. Here, using dictionaries we can store…
-
2
votes1
answer1860
viewsA: How to make a button in PHP, send data to my mysql table?
Change: <button type="button" class="btn btn-block btn-primary">CADASTRAR</button> For: <button type="submit" class="btn btn-block btn-primary">CADASTRAR</button>…
-
2
votes2
answers19928
viewsA: Difference between file_get_contents and Curl ?
file_get_contents besides read all the contents of a file to a string, often is also used for simple requests to urls, although from php 4.3 we can also define other parameters of the request when…
-
2
votes1
answer256
viewsA: Difficulty with Bootstrap responsiveness
That’s happening because you’re inserting row for each column, insert the three columns in the same Row. Do so: *{ box-sizing: border-box; } body{ margin: 0; font-family: Arial, Helvetica,…
-
2
votes1
answer258
viewsA: Problems with update mysql
That’s because it has to make the escape from \, when you want to insert backslashes. Do: UPDATE tabela1 set caminho = 'c:\\logs\\caminho.txt' where cod_tab = 1…
-
2
votes3
answers4110
viewsA: How to get the first item of an object in javascript?
Can do: var obj = { tipo_entrega_id: 10, outro_campo:123 }; var val1 = obj[Object.keys(obj)[0]]; // criar um array com as keys do obj, e depois vamos só buscar a primera, com index 0…
javascriptanswered Miguel 29,306 -
2
votes1
answer2605
viewsA: Is it possible to create an iframe for a specific part of a page?
Yeah, yeah, just put the id of the section you want to appear by default at the end of the url in src. The most you can do is hide the scroll, note that this scroll is not yours, it is the other…
-
3
votes1
answer396
viewsA: Scroll To negative or at the end of anchor
You can subtract the height of the header to the animation of the scroll. EXAMPLE here, I only put customers in this case. This way you can take off the padding-top in each section you put in for…
-
2
votes2
answers643
viewsA: How do I send data from a table html in a form post?
See by here in the console, in jsfiddle. This way you will have the whole table in a query string (click to send) ready to ship: NOTE that you must adjust the Keys (data-field) of each one, not to…
-
3
votes1
answer753
viewsA: Amount of elements in JSON
Do the json_decode in the json string and use Count in the result: $parseJson = json_decode('[{"descricao":"Fotografia","codigo":784},{"descricao":"Filmagem","codigo":789}]'); echo…
-
2
votes2
answers643
viewsA: How do I send data from a table html in a form post?
This gives an idea of how it works. What I did was take advantage of the attributes data and I inserted it in the buttons to then search with javascript: var editBtns =…
-
1
votes1
answer179
viewsA: Set the behavior of the Python window when the mouse is over and outside it
There is a small bug but I will try to get around it. The event however is being detected. import gtk def mouse_enter(win, event): win.set_decorated(True) def mouse_leave(win, event):…
-
1
votes2
answers6574
viewsA: To enable and disable a text type input after a value selected in the combobox
Do the verification in the event change in the select field: $('#idTipoParticipante').on('change', function() { var tipo = $(this).find('option:selected').text().trim(); if(tipo == 'Personagem') {…
-
1
votes2
answers905
viewsA: Make IFRAME or EMBED dynamically pick attribute of clicked link
Do so: <a href="http://www.bbc.com/news/" onclick="abrir(this);return false;">Clique</a> <a href="http://www.abola.pt/" onclick="abrir(this);return false;">Clique</a> <a…
javascriptanswered Miguel 29,306 -
0
votes1
answer104
viewsA: javascript - show/Hide menu does not work
Is this? <script> function dpdShowHide(ele){ dpdOrg = ele.children[0]; if (dpdOrg.style.display == 'none') { dpdOrg.style.display = 'block'; } else{ dpdOrg.style.display = 'none'; } } var…
-
0
votes1
answer529
viewsA: Invalid argument supplied for foreach() Using JSON
It’s a hair problem, change to quotes: <?php $amigos = json_decode('[{"nome":"bruno","email":"[email protected]"}]'); foreach($amigos as $a) { echo $a->nome; // bruno }…