Posts by Miguel • 29,306 points
758 posts
-
1
votes3
answers479
viewsA: Maximum occurrences in a python dictionary
Do: meu_dict = {'A':3, 'B':5, 'C':0, 'D':10, 'E':2} max_value = sorted(meu_dict.items(), key=lambda tup: tup[1])[-1] # ('D', 10)
-
2
votes2
answers8428
viewsA: Pass id of a table data to modal?
I made an example that I think you can adjust to what you want. What I did was for each delete button in the table add attributes date of Html5, is really very useful in these situations, can…
-
2
votes2
answers1278
viewsA: Adding consecutive integers to a list - Python
@Gypsy Morrison has already given you the solution to this problem. But, if you allow me I will give you suggestions for correction: Why the i = 0 at the beginning? It is not necessary, the value of…
python-2.7answered Miguel 29,306 -
2
votes1
answer303
viewsA: Database Modeling, many to many relationship between two tables
I would do so, since the same news can be displayed on 2 or more websites: Create a table Sites with the columns id (1, 2 and 3) and column url (website address, e.g.: www.meusite.com), here you…
-
6
votes3
answers2761
viewsA: Change active menu item depending on scroll
I don’t think this feature has any special name. I made an example where you can get an idea, it was with jquery and not with native javascript. If you don’t help him this way say I withdraw the…
-
1
votes3
answers1065
viewsA: Multiplo INSERT Models Laravel 5
This is because the column cannot be null, ie in the vendor table ve be defined in your database as not null, or you set the default for that column to accept null values. If you have created the…
-
2
votes2
answers1057
viewsQ: Add elements to a list inside a list compreension
I have following code: myList = [1,2,3,4,5] result = [] test = [result.append(i) for i in myList] whose output from test is: [None, None, None, None, None] I’d like to know why, since ex se: test =…
-
2
votes2
answers5842
viewsA: Regex to validate date yyyy/mm/dd?
Example in JSFIDDLE. This way you can validate the date in the formats: yyyy-mm-dd , yyyy/mm/dd , yyyy.mm.dd function data_valida(date) { var matches =…
-
2
votes2
answers3283
viewsA: How to Remove Automatic Bootstrap Slider
Try: $('.carousel').carousel({ pause: true, interval: false });
-
2
votes1
answer581
viewsA: Undefined index: url
If you want to check whether or not there is a parameter that calls url url and, if this does not exist is set to index, then do: $url = 'index'; if(isset($_GET['url'])) { $url = $_GET['url']; $url…
-
0
votes2
answers605
viewsA: Auto-click every 10 seconds
I’ve been taking a look at the site. If you’re working on the home page photo show: jquery: var slideNum = 0; setInterval(function() { jQuery('a.nivo-control').removeClass('active');…
-
0
votes1
answer171
viewsA: Get INPUT_GET of friendly url
If you only have 1 parameter to grab you can do: meusite.com/usuario/dashboard&get=artigos/criar: $param = explode('&', $url); // array('meusite.com/usuario/dashboard', get=artigos/criar)…
-
1
votes2
answers197
views -
0
votes1
answer102
viewsA: generate a php json
json_encode allows the use of bitmask to pass several constants to this method. I have now tested so: <?php $array = json_decode('{ "nodes":[ {"name":"Barry"}, {"name":"Frodo"}, {"name":"Elvis"},…
-
0
votes2
answers201
viewsA: Grab a value stored in a . html link
Can do with recursive setInterval, or setTimeout: With setInterval: <p id="temp"></p> ... <script> function loadTemp() { alert('atualização'); var xhttp = new XMLHttpRequest();…
-
0
votes3
answers13930
viewsA: Change color of an image by hovering the mouse over it
for that the simplest is to even have two images, to look like I think will be the two have exactly the same measure, in this case the images are different but it is only to illustrate: HTML:…
-
1
votes1
answer521
viewsA: Update database with form data without refresh
The error is that you are taking out the value only the value of the input whose the name=ids[] and it is if you are checked. The error is in that line:…
-
0
votes4
answers742
viewsA: What is the difference between PHP’s "Exception"?
It all depends on the exception you want to grab. By EX: try { $PDO = new PDO('...'); } catch( PDOException $Exception ) { echo 'Conexão à base de dados não foi bem sucedida'; } Here you want to…
-
2
votes2
answers1341
viewsA: With setting the deadline in the bootstrap datepicker?
$("#datepicker").datepicker({ endDate : new Date('2016-05-20'), }); Here’s a example
-
1
votes1
answer420
viewsA: How to create a user-customizable javascript-only alert?
Note this method being client-side, is only valid as long as it has not deleted the cookie or the cookie has not expired. Example in JSFIDDLE <script> function readCookie(name) { var nameEQ =…
javascriptanswered Miguel 29,306 -
3
votes2
answers1309
viewsA: Editable table in PHP
Here is a simple example JSFIDDLE: Here the relation is made between the value of the attribute data-show and the name of the input we have in the form $('.edit').on('click', function(){ var dados =…
-
1
votes4
answers485
viewsA: How to determine the index of items in one list in another
Here is a way in which the final variable will store all the present letters of S_names present in other and their index (key): results = [] for i in other: if i in S_names: print i+ ' - '…
-
4
votes1
answer505
viewsA: Set date 7 days/a week ago
Get date from a week/month/year ago: var uma_semana = new Date(); uma_semana.setDate(uma_semana.getDate() - 7); var um_mes = new Date(); um_mes.setMonth(um_mes.getMonth() - 1); var um_ano = new…
-
0
votes2
answers54
viewsA: Error while running a Trigger
I believe with BEFORE you can do this. CREATE TRIGGER actrecibo BEFORE INSERT on Recibos FOR EACH ROW BEGIN SET NEW.id = ( SELECT MAX(id) FROM Recibos ) + 1 END…
-
0
votes3
answers3645
views -
3
votes2
answers78
viewsA: How to take several elements and play on a single item?
$('li').each(function(){ $('.nova-ul').append($(this)); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ul> <li>1 </li>…
-
1
votes2
answers425
viewsA: What’s the difference between "require" and "require-dev"?
Taking this into account. The packages require-dev are not required for your project to work and should not be included in the version that goes into production. These convention packages are for…
-
1
votes3
answers82
viewsA: Javascript - Function problem that adds textbox
Always copy the contents of the last input: $("#addPart").on('click', function() { var newField = $('.inputMGM').last().clone(); $(this).before(newField) }); Example…
-
5
votes1
answer183
viewsA: Imprimir array de Curl
In that case, it will: echo $array_retornado['msg']; // 826
-
1
votes2
answers425
viewsA: How do I get a json answer in javascript/jquery?
Make an ajax call I think is the best way, taking into account that your question is javascript I will post accordingly, keep in mind that with jquery or other libs could greatly reduce this code:…
-
2
votes1
answer41
viewsQ: Facebook dependency for authentication
In many cases, stackoverflow pt being one of them, I log in with Facebook. We now think that I stop wanting to be a part of Facebook and delete my Facebook account. What happens to my account on the…
-
3
votes2
answers520
viewsA: JS parameter for PHP file
Why not make a $_GET? <script type='text/javascript'> ... var parametro = 123; events: "events.php?param=" +parametro; </script> In the file Events.php: $parametro = $_GET['param']; //…
-
2
votes1
answer552
viewsA: Dictionaries receiving list with values
I can’t test this code now. But try every time you add an institution you can also set the donation to 0 on this line can stay: ... instituicoes.append({'nome': instituicao_add, 'doação': 0}) ...…
-
1
votes3
answers65
viewsA: Help with IF and ELSE at session_start()
You can do it like this, I’d do it like this: When the Image is set: session_start(); // isto existe sempre $_SESSION['Logo'] = 'COLOCADA/ADMIN/IMAGEM.jpp'; // Definir uma imagem 'default', caso…
-
1
votes1
answer939
viewsA: Align Vertically Horizontally Aligned Objects
The problem is in those two lines, take it out of the <ul>: ... line-height:100px; ... There are several ways to center vertically/horizontally elements in CSS:…
-
2
votes1
answer229
viewsA: Conversion of response to lists
Okay, I think I get it. You want to store all the institutions typed by the user in a list: Why not make a list of dictionaries where each store the institution’s name and donation? If I have…
-
1
votes4
answers614
viewsA: Writing effect using javascript, setInterval does not work
The parameters are not passed as you are doing: Try: setInterval(escrever, 1000, 'test'); Example in jsfiddle. I don’t know if that’s what you want but so the impression of each letter is…
-
1
votes1
answer1232
viewsA: Create dynamic form array in PHP
You can do it, I’ll do it with jQuery, add jQuery to your tags sff. You can do it as well as example below: HTML: Add friends name/email: <form method="POST"> <div class="campos">…
-
1
votes1
answer328
viewsA: Insert of data passing only $_POST using Laravel
Before any contact with the database the server must ALWAYS validate the inputs via POST and GET, if it comes from HTML/URL form. This depends on whether you want the validations to be equal for all…
-
1
votes1
answer69
viewsA: Check the existence of data in the PHP database
$conteudos = $dados->fetchObject(); $resultado = ''; if (count($conteudos) > 0) { foreach ($conteudos as $user) { $resultado .= 'Existem clientes - (' .$user['nome']. ')'; } } else{ $resultado…
-
0
votes2
answers306
viewsA: How do you send three Curl requests at once?
If you have to fetch 3 servers then there will have to be 3 requests, but one way to do it is to create a function that takes responsibility for all of them: function get_data($url) { $curl =…
-
3
votes3
answers2538
viewsA: Mysql query and case distinguish
You can do this check in php before. To compare strings in DB Mysql here’s this simple way: EX: select 'Miguel' LIKE BINARY 'miguel'; // diferente select 'Miguel' LIKE 'miguel'; // igual That is to…
-
2
votes2
answers63
viewsA: Moving from one function to another
class usuario() { public $userFullname; public function __construct($data) { $this->userFullname = $this->GetHtml($data); } protected function GetHtml($data) { $this->data = $data;…
-
4
votes2
answers2258
viewsA: How can I calculate the width when resizing an image that must be 3 X 4, knowing only the height?
I think mathematically it is: 3x4: Comprimento -> 3 Altura -> 4 That is, suppose we have a height of 600px and do not know the length: (600 * 3) / 4 = comprimento I’m sure you already know,…
-
1
votes2
answers303
viewsA: How to remove Markers one by one(javascript)
If you can make a suggestion to avoid the cycle: <input id="chkOranTarif" type="checkbox" name="chkOranTarif" class="psform__checkbox" onchange="removeMap(this)" data-marker="<MARKER A…
-
1
votes2
answers80
views -
2
votes5
answers1111
viewsA: How do I leave the page open marked in the menu?
This gives with javascript, can do this depending on the page you are on: ex HTML: <nav> <ul> <li class="home"> <a href="#">Home</a> </li> <li…
-
2
votes4
answers8374
viewsA: Change image with CSS Hover
Do with the opacity property, and take advantage of the z-index, so do not need to do anything in the image of .restaurantes_hover: .left_corpo .restaurantes{ position: absolute; height: 30%;…
-
1
votes1
answer166
viewsA: Check if an ID exists on a data-list
Is this what you want? $('.list_details li').on('click',function(){ var cliked = $(this); var found = false; $('.tab_aluno tr').each(function(){ if($(this).attr('id') == cliked.attr('id')) { found =…
-
0
votes2
answers134
viewsA: How do I delete the space that require_once leaves?
I tested exactly as you have. Here is the image of my monitor: I think you must have a margin/padding somewhere and you haven’t noticed, or maybe you have some property that acts on all div…