Posts by Woss • 73,416 points
1,476 posts
-
0
votes3
answers1157
viewsA: Get value from dynamically created fields
Attribute id of an element in HTML serves to define an element single in DOM. That is, add fields dynamically using a id already defined does not make any sense. A reply otaciojb was concerned with…
-
0
votes1
answer313
viewsA: How to hide iframe from JS?
First, only the div.alert is hidden because the this.parentElement refers to this element only, since only the first parent element is searched for. To hide the element iframe, you need to do:…
-
5
votes1
answer645
viewsA: I have one form inside the other and I can’t get the most internal form
Elements form cannot be nested. In the recommendation W3C, as Lucas posted in the comments, says: Flow content, but with in the form element. As practical proof of this, just check in the browser…
-
3
votes1
answer1662
viewsA: How to print all vowels present in string?
str.find The idea you used is very close to the final solution, the main problem is that the method find of string returns only the index of the first occurrence of the search letter. str.find(sub[,…
-
6
votes5
answers12449
viewsA: How to separate a digit from an integer?
To take the digit of the hundred, just divide the value by 100, take only the whole part of the result and, if there are more digits, take the last of the sequence. >>> numero_int = 5…
-
0
votes4
answers2070
viewsA: PHP, how do I stop when the number after . is 0 is hidden?
The simplest way I see is to check if the value is numerically equal to type cast for int his, for "123.00" == (int) "123.00" altarpiece true, while "123.10" == (int) "123.10" altarpiece false. In…
-
1
votes1
answer327
viewsA: Function remove Start List
Let’s imagine that the list consists of the three values: 1, 2 and 3. The pointer p points to the beginning of the list: +---+ +---+ +---+ | 1 | -> | 2 | -> | 3 | +---+ +---+ +---+ ^ p It is…
-
0
votes2
answers1417
viewsA: Find the highest value of any python file
First, let’s consider that the file can have any type of content (both numbers and text), without a defined format. That is, there can be multiple lines and multiple values in each line, and the…
-
3
votes1
answer54
viewsA: Using variables
The concept of functions already exists in CSS, but not in the way you want. The functions that can be used are native to the language and there is no way to define new ones without the use of…
-
0
votes1
answer128
viewsA: View events for a given day with jquery.datapicker
If you inspect the calendar element, you can access the HTML structure generated by the plugin. It is easy to notice that the divs that have related events have the class .c-event, along with an…
-
3
votes1
answer1360
viewsA: Problem adding month to a php date
In short, the problem is that you are changing the original instance of the start date, so this way when you add 1 month to the start date, this will be 28/02, that is, $date will become 28/02; when…
-
4
votes3
answers52823
viewsA: How to get current url with PHP
As stated in the comments, the content of the global variable $_SERVER["REQUEST_URI"] is the way: Novo/adm/categoria/1-Nome_Categoria It was also stated in the comments that the content of interest…
-
0
votes2
answers2971
viewsA: Line break
Let’s consider that your PHP code generates the following result: Kevin T. Sullivan<br /> Nicolash Correia Cunha<br /> Lavinia Azevedo Lima<br /> Isabelle Lima Silva<br />…
-
4
votes1
answer322
viewsA: What’s wrong with my Python code?
See the function documentation download: """ Downloads the file of the URL defined within the class instance. Keyword arguments: path -- Destination directory chunk_size -- File size (in bytes) to…
-
6
votes1
answer6079
viewsA: What is the head tag for in html?
What’s the tag for <head>? The element head represents a collection of metadata for the document. Metadata is, as its name says, data about the data. Briefly, you can give the browser some…
-
5
votes7
answers1017
viewsA: Is there any way to know if an array is associative or sequential?
Considerations In accordance with official documentation, one array may only have keys of the whole type or strings. The value can be of any type. The key can be an integer or a string. The value…
-
3
votes1
answer5762
viewsA: Unboundlocalerror: local variable 'adversario_1' referenced before assignment
The problem is in the function torneio. The value of the variable is returned adversario_1, but this is defined only within the while. If, in the first line, candidato_1 = aleatorio(), has already…
python-2.7answered Woss 73,416 -
2
votes1
answer106
viewsA: How to align list items
I believe that using the display: inline in the element p is what complicates everything. Alternatively, you can position the element li:before absolute form and set a left margin for the element p.…
-
6
votes3
answers6054
viewsA: Draw a rectangle using Python repeating structures
Workaround As commented, a simpler solution is to use the multiplication of strings in Python: # Lê o tamanho do retângulo: largura = int(input("digite a largura:")) altura = int(input("digite a…
-
2
votes1
answer2019
viewsA: Sum the diagonals of a matrix
Solution only implementing the logic of sums, as required, without working with threads. Logic, as I commented here, to define the secondary diagonals is to verify the sum between the position of…
-
1
votes2
answers332
viewsA: Calculation of the smallest divisible number giving infinite loop in C
A very practical solution (explanations in the comments in the code): // Define o range de divisores: const unsigned short MAX = 20; int main(int argc, char const *argv[]) { // Resultado, do tipo…
-
3
votes2
answers68
viewsA: Simplify the use of multiple Places all
Considering the text: const value = `{ "ip": "187.155.67.279", "hostname": "b1c33eb3.virtua.com.br", "city": "Leblon", "region": "Rio de Janeiro", "country": "BR", "loc": "-22.8244,-43.0353", "org":…
-
2
votes2
answers101
viewsA: how to change the class of an element according to the position of values within a foreach?
If the idea is only to define the class of the element according to the position of the values in the array, just increase the value of $list, instead of assigning the doir value. Something like:…
-
0
votes1
answer155
viewsA: I want to add all the points of all teachers and create a rank with the top 3
Considering the following table, based on the question displayed: create table aula ( `id` int unsigned auto_increment primary key, `data` date, `titulo` varchar(255), `professor_id` int, `votos`…
-
1
votes2
answers48
viewsA: How to show only the completed data of a query to the database
Just check that the value is not null with the function empty. foreach ($consulta as $pos) { echo !empty($pos['pos']) ? "<li>{$pos['pos']}</li>" : null; } If the value is not empty,…
-
1
votes1
answer124
viewsA: Script to show capital of selected state?
Based on your code, one way is to store the capitals of each state in a custom attribute in the elements option. In case, I called it data-capital. With Javascript, I searched the element select…
-
3
votes1
answer896
viewsA: Reference and Parameter in Python
As discussed in the comments, you confused class attribute with instance attribute. When defining the form attribute: class Foo: attribute = ["Hello"] def add(self, value):…
-
2
votes1
answer55
viewsA: Laravel date error
The error message is very clear: values that should be string are objects. Turns out using Blade, when you do: {{ $var }} The value of $var shall be taken over htmlentities PHP and the same expects…
-
2
votes2
answers701
viewsA: Json parse array
Simply assign the respective object values to the variables: const resposta = { "users":[ { "id":1, "Name":"Rafael", "label":"teste" }, { "id":2, "Name":"Carlos", "label":"teste" } ], "relations":[…
-
3
votes1
answer3392
viewsA: Delete blank lines
Press the shortcut CTRL+H or get into Find/Replace. Look for ^\s* in the field Find What and replace with nothing (leave the field Replace With blank). Make sure to enable regular expression search…
-
2
votes2
answers8348
viewsA: Sum of elements in lists
Consider the entry list: values = [[3, 2, 7], [8, -2, 5], [-1, 4, 3], [2, 2, -9]] Wishing to add the values of each list to a given index, we must then reset the list according to our need. To do…
-
3
votes1
answer589
viewsA: Alphabetical sorting in Array with objects in PHP array
Given the input: $values = [ 0 => ['id' => 1, 'nome' => "b parceiro um", 'status' => true, 'descricao' => "<p>Descrição do parceiro</p>"], 1 => ['id' => 3, 'nome'…
-
7
votes3
answers425
viewsA: Difference between '$()' and 'jQuery()'
Just completing the answer from Lucas and of Renan, to be clearer, just check the source code of the library: define( [ "../core" ], function( jQuery, noGlobal ) { "use strict"; var // Map over…
-
7
votes1
answer178
viewsA: What is the iterable type of PHP 7.1 for?
He’s not a guy, he’s a pseudo guy (just like callable). Its function is to indicate that the function accepts as a parameter both array as any object implementing the interface Traversable. That is,…
-
8
votes1
answer1298
viewsA: How to get the name of the current function?
__FUNCTION__ As of version 4.3.0 of PHP there is a magic constant __FUNCTION__ that makes exactly this function: class Foo { public function method() { echo __FUNCTION__ ; } } $f = new Foo();…
-
2
votes1
answer53
viewsA: Is there a difference between the codes A and B below?
In the way presented, there is no difference. In fact, the function itself click can be considered as a shortcut to the function on, with the parameter click, with some caveats. The function click…
-
6
votes2
answers883
viewsA: How to check if a method exists in a Python class?
Problem: Let us consider the following context: class Call: def __call__(self): pass class Foo: def __init__(self): self.var = Call() def method(self): pass foo = Foo() I mean, we have an object foo…
-
2
votes2
answers77
viewsA: How to extract this information in a string?
A solution very similar to that presented by Guilherme, but with a little less code, can be implemented as: if (preg_match_all('/Stream\s[#](\d+:\d+)(\(\w+\))?:(\s\w+|)[ :]+(\w+|)/i', $resposta,…
-
1
votes5
answers721
viewsA: Element with different end size than width and height definition in CSS?
You can use the property border-box of the CSS, as below: div { width: 300px; height: 100px; border: 1px solid red; padding: 50px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box;…
-
0
votes1
answer112
viewsA: Limit the amount of files that will be displayed in a directory
If we consider the file modification date, we can do the following: // Recupera a lista de todos os arquivos: $files = glob("/arquivos/*"); // Ordena os arquivos pela data de modificacão:…
-
4
votes1
answer63
viewsA: Best way to apply the concept of Object Orientation
One way is to use the compositional concept. If your Webservice requires a user to use the API, you can do something like: class Usuario {...} class WebService { private $user; public function…
-
0
votes1
answer78
viewsA: Working with DOM elements generated by a PHP loop
The problem is that the property id HTML defines unique elements on the page and it makes no sense to define them within a PHP loop, since the elements will be repeated. This way when you assign the…
-
7
votes4
answers16556
viewsA: Generate random numbers in Python without repeating
Just check if the drawn value no longer belongs to the list, and if it does, draw another one. Something like: result = [] while len(result) != 4: r = randint(0, 100) if r not in result:…
-
1
votes1
answer41
viewsA: Insert values Inside table using javascript
If I understand correctly, the problem is just searching with Javascript an element whose id is exibe1 as long as the desired element is id defined has. You can then properly define the property in…
-
4
votes1
answer2138
viewsA: Geolocation in PHP
You can use the API of this website. Apparently the free version allows up to 1000 daily requests. With PHP, the code can be quite simple: $ip = $_SERVER['REMOTE_ADDR']; $details =…
-
6
votes1
answer267
viewsA: Python conditional deviation
Syntax Let’s first start with the syntax errors. import utf8 input ("Digite valor de A ") input ("Digite valor de B ") input ("Digite valor de C ") if (a > b): if (a > c): print("valor maior…
-
4
votes2
answers593
viewsA: What is the difference between project ("project") and application ("app") in Django?
First, let’s look at the directory structure that is generated when we create a project: mysite/ manage.py mysite/ __init__.py settings.py urls.py wsgi.py Project created with the command…
-
0
votes1
answer288
viewsA: Blank marking - Atom
This is a useful practice when you want to prevent invisible characters from being in your code without your consent. Especially when a chunk of code is copied from somewhere else (a website, for…
-
16
votes1
answer880
viewsA: How do >, + , ~ selectors work in CSS?
There is difference of use div p instead of div > p? Yes, there is. The dial div p reaches all elements p which are within an element div, but this does not apply only to direct children. Any…
-
28
votes2
answers5894
viewsA: How and where does tabindex work?
The estate tabindex defines how an element should behave when navigating through the keyboard, serving mainly to build accessibility of an application, since many people with some kind of…