Posts by Woss • 73,416 points
1,476 posts
-
1
votes2
answers1669
viewsA: Convert string to JSON
According to the example you indicated on Jsfiddle, the value you get from select is already a array, therefore the solution of Aline should work: // Valor que vem do multi-select: var values =…
-
1
votes1
answer180
views -
0
votes1
answer35
viewsA: Jump to Section after selecting option
First, I advise you to modify your select and add an attribute in options concerning which section you want to view. For custom attributes, use the prefix data-. For example, we can define an…
javascriptanswered Woss 73,416 -
6
votes4
answers11441
viewsA: A list to receive 20 whole numbers and store in a list and print the largest element in the list
To get the highest value in a list of numbers, there is the native function max: numeros = [1, 2, 3, 4, 5] print("Maior número da lista é:", max(numeros)) Returns the message: Maior número da lista…
-
1
votes1
answer78
viewsA: Error while creating php mysql line chart
Lacked a dataType: "json" in your AJAX request. The way you did, data comes as string, not a Javascript object. It should look like: $.ajax({ url : "http://localhost:8080/cha/data.php", type :…
-
2
votes1
answer80
viewsA: Logic to display data - Slice days
Solution // Intervalos vindos do banco de dados: $dates = [ ["2017-05-08 11:28:40", "2017-05-08 17:52:12"], ["2017-05-08 18:34:02", "2017-05-10 09:02:57"], ["2017-05-10 09:44:31", "2017-05-10…
-
0
votes1
answer273
viewsA: Function to show the element id of a page in a <span id="span"></span>
Just look for the attribute id of the element in question with event.target.getAttribute and set the value in span desired. const span = document.getElementById("span"); document.onmouseover =…
javascriptanswered Woss 73,416 -
2
votes1
answer1246
viewsA: Error consuming json using ajax
Your JSON return seems to be correct, what it does not seem is the way you treat it. $.ajax({ type: "GET", url: "ServiceRestPub/ServiceUsuario.svc/ConsultarRegistroPorCodigo/" + value, contentType:…
-
1
votes2
answers794
viewsA: Sidebar with accordion effect
See an example using the component dropdown bootstrap: By clicking on Execute, visualize in Whole page, to the right of the Run button. <script…
-
2
votes1
answer49
viewsA: Warning: Division by zero with dates
The mistake happens because you are using $diasC as denominator. The value of this variable is defined in the previous line: $diasC = (int) floor($diff / (60 * 60 * 24)); That is, if the difference…
-
0
votes2
answers3154
viewsA: Sum values of a TD with Avascript
Your attempt to mix jQuery with Javascript vanilla Just to select elements of the DOM became very strange. It works, but there is no reason to do it, it leaves the code inconsistent. If you’re using…
-
1
votes1
answer461
viewsA: Insert multiple html with ajax
Just iterate on the result of the AJAX request and use the function append jQuery to insert the element into the DOM. It should look like this: musicas: function(){ $.ajax({ url:…
-
3
votes2
answers1150
viewsA: Animated placeholder
I believe using the placeholder there is no way to do due to its standard functioning, which is to disappear when the length of the value of the input is greater than zero. A way not so simple, but…
-
3
votes2
answers700
viewsA: Add the results for x in range
Using list comprehension, would be: soma = sum(2*k**2 for k in range(5, 10)) Read: for each value of k in the interval range(5, 10) calculate 2*k**2 and add up all the results. You can read more…
-
5
votes2
answers161
viewsA: Don’t events work with dynamic video?
The problem is that the event timeupdate is not a Bubble Event. This means that you cannot treat it through the parent element, as done in: $(document).on("timeupdate", "#video", function(){…
-
3
votes2
answers1718
viewsA: Picking numbers separated by a dot and comma in PHP
Just use the native function explode: array explode ( string $delimiter , string $string [, int $limit ] ) The first parameter is the delimiter, that is, the expression you want to use as reference…
-
0
votes2
answers356
viewsA: How to use . htaccess with 2 arguments
Just completing William’s reply. If you need to redirect other Urls, you can do something like: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d…
-
0
votes1
answer916
viewsA: Object of class mysqli could not be converted to string
As widely discussed in chat, the error is in using the object $conn within your query, as highlighted below: $row_results = mysqli_query($conn, "SELECT * FROM books WHERE (`Title` LIKE…
-
6
votes1
answer3271
viewsA: Is it possible to save the canvas as an image, and send it to the server?
You can get the image on the client side with Javascript and send it to your server with an asynchronous request (AJAX). Imagine there is a button on the page Save, that when the user presses, sends…
-
2
votes1
answer204
viewsA: Set Timezone for all Datetime returned from server
If the dates come in the UTC standard of the external server, there is not much you do but manually correcting as you did. Remember that when creating an object DateTime without specifying the…
-
3
votes1
answer219
viewsA: A subclass or daughter class inherits the interface of its mother class as well?
When you set the interface in a parent class, the daughter class will also suffer the same effect. That is, if the class Conta implements the interface ContaUsuario, the class Aluno, who inherits…
-
2
votes1
answer219
viewsA: Model of the Mongodb
It is a standard behavior of Mongoose that defines the name of collection as the plural of the name of model, therefore person turned people and teste turned testes. You can override this behavior…
-
2
votes1
answer61
viewsA: How to remove increment from Kmllayers in Google Maps?
The only change I made was to define the variable ctaLayer overall and, before defining the new layer, clear the map with ctaLayer.setMap(null), thus, if there is layers previous, it excludes. To…
-
2
votes1
answer100
viewsA: Odd results when calculating factorial
This happens because the type value int is at most 2,147,483,647. If you calculate the factorial of 13, you will see that it is worth 6.227.020.800, that is, it is already impossible to represent…
-
7
votes2
answers3247
viewsA: Separating strings from an Arraylist with comma
No need for a loop, the class itself String has a method called join that converts a list into string, using another string as a separator. List<String> nomes = Arrays.asList("Paulo", "Ana",…
-
4
votes1
answer1306
viewsA: Python / Django interval of hours
You can use the module datetime, with the guys datetime, timedelta and time. The only detail is that you will need to inform a date, that is, year, month and day, however, as we are only interested…
-
1
votes1
answer208
viewsA: Write to BD without mask applied by jQuery
I see two options: (1) treat client-side value with Javascript (2) treat server-side value with C#. For full guarantee, you can implement both forms. Javascript With Javascript, you can assign a…
-
1
votes1
answer7924
viewsA: CSS - positioning an element on the right
First, it doesn’t make much sense to define you in element div within an element tr. The browser understands and displays the element, but semantically this makes the least sense. Second, there is…
-
0
votes1
answer222
viewsA: Javascript - validate form if clickado
Whereas you want to check the fields doornumber, road, postcode and country only if differentAddress is selected, you can do something like: // Pega o elemento checkbox: var differentAddress =…
-
2
votes1
answer1004
viewsA: Permissions error when trying to send a PHP file
For references, the code in question was developed in this question. What happens is that in the code, more precisely in line !chmod($pasta, 0755), you are trying to change the permissions of the…
-
8
votes3
answers69151
viewsA: Vectors in Python
The shortest answer is: it doesn’t define. Python is a high-level programming language and dynamic typing, you do not need to limit the size of your vector. In fact, the type in Python that most…
-
0
votes2
answers2897
viewsA: Get relative path to the directory where the index.php file is located
Consider the folder and file structure: public_html/ folder/ file.php menu.php index.php sobre.php contato.php The directory public_html will be the root of your application. You can create any link…
-
7
votes3
answers85
viewsA: How does variable p work in this code?
The second function parameter find sets the offset relative to the text. This is, s.find("tigre", 0) will seek the first occurrence of the word "tiger" from position 0 of s, already s.find("tigre",…
-
0
votes1
answer99
viewsA: Fetch data in one array if a specific data exists in another
If you’re sure all the id of $array1 exist in the $array2, you don’t need to check if the id is the same, just search the record for the id in $array2 and obtain the value of nome: foreach ($array1…
-
7
votes2
answers2689
viewsA: Recursive Functions in Javascript
To facilitate the response, take as an example the factorial of 5. var resultado = recursiveFatorial(5); // 120 The variable resultado will be allocated in memory and its value will be the return of…
-
3
votes2
answers1055
viewsA: Convert seconds to timestamp?
Solution A solution using regular expressions would be, making only the second value mandatory: function convert($value) { if…
-
4
votes2
answers27
viewsA: Define size in px based on size in %
Your code: function resizeImagePreview(){ var imageHolder = document.getElementById("image-holder"); imageHolder.style.width = "25%"; console.log(imageHolder.style.width); imageHolder.style.height =…
javascriptanswered Woss 73,416 -
1
votes1
answer2505
viewsA: Take data from a textarea and fill HTML table
When you do: var retorno = valor.split(" "); You are considering all the content of the textarea as just one line. Even if you have more rows, your code will understand as multiple columns. The…
-
0
votes1
answer31
views -
1
votes3
answers842
viewsA: Do you have to make the user type the number of rows and columns of a table and this table appears in PHP?
By focusing only on the PHP part, you can use the loop loop for: function generate_html_table ($rows, $cols) { // Se linha ou coluna for menor ou igual a zero // retorna uma string vazia if ($rows…
-
2
votes2
answers1545
viewsA: How to check if Data X is newer than Data Y?
Assuming you have these dates in some defined format, you can use the class DateTime of PHP: $dt_local = DateTime::createFromFormat('d-m-Y', '03-04-2017'); $dt_remoto =…
-
3
votes1
answer1090
views -
7
votes2
answers4682
viewsA: How to replace letter typed in python?
Remember that in Python 3, it is used input in place of raw_input. As the question uses the second, it is assumed that it refers to Python 2. The best way is by using the method translate of the…
-
2
votes2
answers516
viewsA: Show PHP error in Atom
Version used: Atom 1.14.4 x64. Some details may vary depending on the editor’s version and configuration, such as language. Linter PHP To display syntax errors, you can make use of the package…
-
5
votes1
answer3388
viewsA: Assign event click to button added to DOM with jQuery
First, the attribute of id HTML defines unique elements in the document, so create multiple buttons with id="negacao" makes no sense and is semantically wrong. Second, when you assign a function to…
-
2
votes1
answer3770
viewsA: Django, data’d/m/Y format configuration
According to the settings of Django, there’s the property DATE_INPUT_FORMATS: A list of formats that will be accepted when inputting data on a date field. That is, the list of formats that will be…
-
4
votes2
answers16445
viewsA: How do I delete a file from a python folder
To remove a file, you can use the function os.remove(path) : import os def etc(): path = "diretorio"` dir = os.listdir(path) for file in dir: if file == "arquivo.txt": os.remove(file) The above…
-
1
votes1
answer1390
viewsA: Mouse image display text and vanish image (vice versa)
The loop infinite happens because when you do $(this).hide(), the image is removed from the GIFT and therefore the mouse is no longer on the element, triggering the event handlerOut of hover.…
-
17
votes3
answers22473
viewsA: What is "with" in Python for?
Syntax The syntax of the declaration with is: with EXPR as VAR: BLOCK with and as are reserved words of language. EXPR is an arbitrary expression (but not a list of expressions), and VAR is a single…
-
7
votes3
answers570
viewsA: How to jump from one tab to the other in Sublime Text?
There is the documentation unofficial who informs: Ctrl+Shift+T: Opens the last closed tab; Ctrl + Pgup: Move to the tab above; Ctrl + Pgdn: Move to the tab below; Ctrl + W: Close the current tab;…
sublime-textanswered Woss 73,416