Posts by Miguel • 29,306 points
758 posts
-
3
votes2
answers100
viewsA: Error capturing checked attribute
I think you forgot to "#" on $('#doacao-proximo-1'). But try it like this: $('#caption-item-1').click(function(){ if($('#boleto-input').is(':checked')) { // <-- altera aqui…
-
2
votes3
answers1216
viewsA: Count elements and display a quantity
You can do it like this, using the selector gt (Greater than) , and all p s with an index higher than 0, in this case, you have display: none (hide()): $('p:gt(0)').hide(); <script…
-
9
votes2
answers15546
viewsA: Event key enter into input
You can do it like this: const inputEle = document.getElementById('enter'); inputEle.addEventListener('keyup', function(e){ var key = e.which || e.keyCode; if (key == 13) { // codigo da tecla enter…
-
2
votes2
answers2519
viewsA: How to compress a folder with everything inside using python zipfile?
The problem is that you need to recursively specify the directories/files within the directory Tudo and others you may want, you get this via os.walk(), and because of the fact that registro.py not…
-
0
votes1
answer340
viewsA: Slidedown effect with menus li
I think there’s no need for Animation in css. You can do it like this: $('.open-link').on('click', function() { $('.box').toggleClass('open'); }); .box { width: 200px; border: 1px solid blue;…
-
3
votes1
answer1377
views -
4
votes4
answers810
viewsA: Python, How to let the person put a number and with this number put that same amount of questions
I didn’t quite get the medium part, but here’s a solution to your material storage problem: materias = [] qtd_materias = None while not isinstance(qtd_materias, int): try: qtd_materias =…
-
7
votes4
answers8175
viewsA: What is the opposite of the "None display"?
Actually the display by default (if you do not declare otherwise) depends on the element, in case it is div the display default is block, already for example in an image or span (<img>,…
-
7
votes3
answers11972
viewsA: Updating page after time
You can do that only with HTML: <meta http-equiv="refresh" content="180"> Where content is the waiting time (in seconds) until refresh With javascript (you don’t even need jquery), try putting…
-
2
votes1
answer90
viewsA: Sort products interchange according to flag
Now, my advice is to bring two sets of results from the database, remember that you can sort them when you go to the database, ex: ...->orderBy('preco', 'DESC'); $feat = Product::where('feature',…
-
3
votes1
answer94
viewsA: a bug in the range() function?
Now Jeacom, you had a subtle mistake, that’s how: in this block where people self.grid in init: for x in range(width): for y in range(heigth): self.grid[x, y] = 0 You’re so popular like this:…
-
4
votes1
answer169
viewsA: I want to count and quantify the Array index on onclick control
You can do it like this: var elemento = new Array(1, 2, 3, 2, 7); var contar = 0; var ele_len = elemento.length; const spn = document.getElementById('numero'); const menos_btn =…
-
6
votes1
answer1567
viewsA: Onload event for iframe
You can use the event load, that will be fired when all resources are loaded: const iframe = document.getElementById('iframe'); window.addEventListener("load", function(event) { console.log('Está…
-
4
votes3
answers4343
viewsA: How to download file without back-end
You can do it like this, if I understand correctly, using the attribute download: <a href="http://www.w3schools.com/css/trolltunga.jpg" download>download</a> In your case I’d be: <a…
-
2
votes1
answer45
viewsA: The Rule is not applying to the elements
Since classes are part of the same element css selectors should run out of space: .mc.c0 { color: red; } .mc.s1 { font-style: italic; } <span class="mc c0 s1">Olá Mundo :D</span> Because…
-
12
votes2
answers319
viewsQ: Document.getElementById('ID'). func(....) vs ID.func(...)
Yesterday I came across a curious thing, I had no idea you could do it this way. Until now I did it this way: document.getElementById('a').innerHTML = 'CONTENT'; <div id="a"></div> But…
-
1
votes2
answers89
viewsA: When uploading, the file name becomes the title
You can do it like this: $('#file').on('change', function() { var f_name = $(this)[0].files[0].name; $('#name_file').val(f_name); }); <script…
-
4
votes1
answer913
viewsA: Infinite counting of ordinal numbers and exposing in HTML document
It’ll be something like this? const eleResult = document.getElementById('contador'); var n = 0; window.setInterval(function() { eleResult.innerHTML += n+ ' '; n++; }, 100); // ajustas o tempo em…
-
3
votes2
answers2703
viewsA: How to skip the line in writing the files?
To skip a line when writing a file: ... #Tentativa de Pular linha arqTeste.write("\n") ... To concatenate variables to a string you can do so: ... #É essa a minha outra dúvida, não sei como fazer…
-
1
votes2
answers2295
viewsA: How to do when clicking a button appear a form with js?
You can do it like this: var btn = document.getElementById('btn_form'); var form = document.getElementById('my_form'); btn.addEventListener('click', function() { form.style.display = 'block'; });…
-
2
votes1
answer138
viewsA: Check index in Dict
In the comparison check first if result is None, and only then if the key exists: result = None a = result['my_key'] if result is not None and 'my_key' in result else None print(a) # None ... result…
-
2
votes1
answer3296
viewsA: How to make a text fit the size of the Tkinter screen?
Using the argument wraplength you can make the text inside the label have a specific dimension, I put the same dimension of the window: from tkinter import * win_width, win_height = 750, 600 janela1…
-
1
votes2
answers812
viewsA: Insert points into a map with an array that passes through the database
You can do so on the client side, dynamically add a zone to your map, by default you already have an area in the input ready to test, not far from the locations you already have there (PS: Always…
-
13
votes5
answers5611
viewsA: Draw square on the canvas using wire fences (#)
Is this? largura = int(input("Digite a largura: ")) altura = int(input("Digite a altura: ")) for _ in range(altura): # por cada linha print('#'*largura) # imprimimos a largura * # DEMONSTRATION If…
-
0
votes2
answers251
viewsA: Problem with logout in system Aravel 5.3
When you create your migrations add a column to that table: ... $table->rememberToken(); ... You can also do it manually by adding the column remember_token with the default value NULL on your…
-
6
votes2
answers622
viewsQ: Canvas delete correct text
I do research and there is no way to make it work, the first try works well, but the second no longer, that is, it does not erase the text that was there and replace it with the new one (in the…
-
6
votes2
answers4614
viewsQ: Character size (ASCII vs other encodings) in bytes
Seeing this issue a doubt arose, coming from PHP and in the past having "problems" derived from character encoding, ex: srtpos vs mb_strpos, i knew that all ASCII characters have 1 byte, but I…
-
2
votes3
answers1740
viewsA: How do I know how much memory my application uses in PHP?
memory_get_usage: memory_get_usage() returns the amount of byte memory that is being used by your php script. DEMONSTRATION: echo memory_get_usage(); // 112388 (bytes) If you put the argument as…
-
3
votes2
answers545
viewsA: Problems with the result Curl and file_get_contents
I just tested here successfully: It can actually be simpler than what you were doing: function getimg($url) { $process = curl_init(); curl_setopt($process, CURLOPT_URL, $url); curl_setopt($process,…
-
2
votes1
answer1542
viewsA: Jquery Validate - Mark at least 1 checkbox true
This is a solution without the validate plugin. Checking at least one, I had to rename the input class because it was giving me an error. unrecognized Expression: . checkbox[]:checked I switched to…
-
6
votes1
answer71
viewsA: When should I include ".. /" in the path to a include or image?
Of course I do, there’s a rule one.jpg in the file index.php within the following structure: -index.php -imgs - one.jpg - two.jpg ... For this case above you would use so: imgs/one.jpg Another case…
-
4
votes1
answer705
viewsA: Access Dict within list
Here’s what you can do: dic = {"foreignNames":[ { "name":"Archange Avacyn", "language":"French", "multiverseid":411061 }, { "name":"Erzengel Avacyn", "language":"German", "multiverseid":410731 }, {…
-
5
votes2
answers836
viewsA: Click button more using list (li)
You can do it like this: const load_num = 10; var times_loaded = 1; $('li:gt(' +(load_num-1)+ ')').hide(); // esconder as li cujo index >= 10 $('#load_more').on('click', function() { times_loaded…
-
2
votes1
answer193
viewsA: Python Using . replace() with list comprehension
Try this, not with list compreession but the logic to be adopted will be this: ab = zip(a, b) # relacionar os elementis das listas for a_val, b_val in ab: txt = txt.replace(a_val, b_val)…
-
4
votes2
answers11695
viewsA: Definition : Document.getElementById
Note that JSON has nothing to do with Javascript with respect to its purpose, JSON is just like XML, serves to be read/manipulated by software, just a format that allows the communication of…
javascriptanswered Miguel 29,306 -
4
votes1
answer485
viewsA: Compress and unzip file in memory
If I understand correctly you can do the following: from zipfile import * import os zip_name = 'my_zip.zip' # caminho para o zip file_to_zip = 'file.txt' # caminho para o ficheiro a inserir no zip…
-
0
votes2
answers359
viewsA: Timeout when trying to access a HTTPS Rest service via PHP
By the analysis I did the API service requires that there is a User-Agent defined (I believe the problem arises from it), this approach does not involve \Httpful\Request and I don’t even think it’s…
-
2
votes1
answer181
viewsA: Send form to controller with ajax
My suggestion is that in the controller, after processing the data sent in the controller, you redirect to the same page with a flag: $urlBack = url()->previous(); // buscar o url anterior,…
-
2
votes1
answer40
viewsA: Swap image or image color in virtual store
You can do it this way, given that this is obviously not the same product or colors, but the logic will be this: const prod_colors = {blue:…
-
4
votes2
answers7326
viewsA: What is the correct way to call Python methods?
Inside the class you must put self, equivalent to $this in PHP, or this in Java in the call of a method, but it has a particularity, is that it is defined that it enters as argument also in the…
-
2
votes2
answers134
viewsA: Check ip, register in array, convert to json and write to file
Let’s go through the json objects and see if any of them match the visitor’s ip ($new_ip, in this case), in which case the $jsonRaw will come from the file in your case, ex: $jsonRaw =…
-
9
votes4
answers4863
viewsA: How to pick the first word of a string with jquery?
In reality you don’t even need jQuery, "with jQuery" would be the same: var strg = 'Primeira palavra da string'; var word_one = strg.split(' ')[0];// separar str por espaços console.log(word_one);…
-
6
votes4
answers5196
views -
1
votes3
answers363
viewsA: Print values from the same variable via GET PHP
If I understand correctly you can do the following: foreach($_GET as $key => $val) { echo $key. ': ' .$val; } In which $key will be for example cod_igreja and the $val respective will be 4355 in…
-
2
votes1
answer59
viewsA: Why is this server crashing?
Corrected, I must start by saying that variables with special characters (ç, ã ...) is not at all advised, and with capital in the first letter is also unconventional. You were also doing two cycles…
-
8
votes1
answer478
viewsA: Match all coordinates x, y, z from a list of tuples
You can do it using zip(): coords = [(14, 9, 7), (11, 1, 20), (1, 1, 7), (13, 9, 1), (9, 13, 4), (20, 1, 4), (17, 6, 8), (14, 10, 1), (14, 2, 17), (7, 20, 7)] combin = zip(*coords) # aqui fazes…
-
1
votes1
answer273
viewsA: Problems with session Standard 5.3
That’s specified and I don’t see why in this version (5.3) they did so, but the truth is that accessing the authenticated session/user in the constructor is no longer supported, not long ago either…
-
1
votes1
answer104
viewsA: How to use decrement in Laravel 5.2 using data from an array?
The ids and quantities will already be a server-side array, What you have to do afterwards when you receive the data in your controller is: ... foreach($request->get('id') as $key => $id) {…
-
1
votes1
answer934
viewsA: Receive id in modal to delete record
Try the following: $('a[data-target="#delete-modal"]').on('click', function (e) { e.preventDefault(); var nome = $(this).data('nome'); var id = $(this).data('id'); $('span.nome').text(nome + ' (id =…
-
17
votes4
answers2392
viewsA: NPM, Bower and Composer, which one to use?
Yes correct, they are all package managers. But, the type of packages they manage is different. I can begin by explaining that Composer is a package manager focused on php (there are exceptions, for…