Posts by Valdeir Psr • 10,804 points
433 posts
-
2
votes1
answer69
viewsA: What is git send-email for?
Let’s go by part. Purpose of the command send-email GIT was born at a time when it was very common for programmers and enthusiasts to get together in communities and forums to debate and program.…
-
3
votes1
answer99
viewsA: Replace javascript modifies only the last term
Let’s go step by step. Searching words with Regexp One of the ways to search a word is to use the metacharacter \b, or Word Boundary, available in Regex. With it, there are three different positions…
javascriptanswered Valdeir Psr 10,804 -
2
votes1
answer276
viewsA: How to put the states taken from the ibge site in alphabetical order?
To organize a particular array, the Javascript provides a call function sort. According to the documentation, you can pass a function to have custom criteria. This function must return one of the…
javascriptanswered Valdeir Psr 10,804 -
2
votes2
answers197
viewsA: How to center and change order in flexbox
Get to the points. Centering items To center the items of tag <article>, just use the property align-items in your CSS, that way you could choose how they will be aligned horizontally, in your…
-
0
votes2
answers34
viewsA: Link Event to TAG Class exclusion
There are a few ways. When an element about the click action, the Javascript, automatically, pass a type parameter Eventtarget. With this parameter, we can access the clicked element and all its…
-
3
votes2
answers63
viewsA: Condition other than in javascript
Beyond the if..else and of switch, that have already been presented, you can also use Object and verify the Keys. If a key exists, returns the affiliate attached to it; otherwise, returns the…
javascriptanswered Valdeir Psr 10,804 -
2
votes1
answer909
viewsA: How to create a link with Vue in the <a> tag?
According to the documentation of Vuejs, attributes do not work with keys {{ }}. To make an attribute dynamic, you need to use the directive v-bind (or simply :attribute). Example: var app = new…
vue.jsanswered Valdeir Psr 10,804 -
1
votes1
answer38
viewsA: Insert content into Webcomponents template
One of the ways to add content to a custom element is to use the element <slot> This element is part of the technology of Web Components of Javascript. With it it is possible to replace or add…
-
2
votes1
answer102
viewsA: How to correctly check the status of a Checkbox in js?
There are some ways: Add class idPai in grandchildren. Ex: class="form-check-input filhoidOption2 idPai"; or Use a class with the name that has all levels. Ex: class="pai", class="filho-1",…
-
3
votes2
answers1590
viewsA: Promise {status: "pending"}
There are two errors in your code: You are not "waiting" for the result of Promise; You are returning the result in the function onreadystatechange, and the return should be in the function…
-
3
votes1
answer173
viewsA: Group products by vuejs categories
Categories are repeating as you are using the first v-for with the products, instead of using the product variable. What you need to do is scroll through the categories as this, you filter the…
vue.jsanswered Valdeir Psr 10,804 -
1
votes2
answers132
viewsA: Error in a Function with callback
It turns out that when the code const usuario = getUser(); is executed, the function getUser should receive a callback. There are some ways to correct this error. In the first, we can verify whether…
-
1
votes1
answer351
viewsA: Pause running using Sweetalert (swal, Javascript)
To pause a while, you can use Promises. Like the framework Sweetalert2 works with this, so just use the operator await. Example: document.querySelector('button') /** * Utiliza o operador `async`…
-
0
votes2
answers71
viewsA: How do I show this element otherwise than in an Alert so?
Already several ways to do this. Below I explain two of them. Concatenation To merge several texts into a single variable, just use concatenation (join) the texts. In Javascript you can use the…
javascriptanswered Valdeir Psr 10,804 -
1
votes2
answers176
viewsA: How to create a single search box for Google and Wikipedia?
You don’t have to use language back-end to that end. With Javascript it is possible to do what you wish. This can be done by treating the "click" event of the buttons. This way we can create an…
-
2
votes1
answer81
viewsA: Problem for "Save image as" php
Just change the header Content-disposition. Header According to RFC6266, "the header field Content-Disposition is used to transmit additional information on how to process the payload of the…
-
6
votes2
answers583
viewsA: What makes "group by 1" and why it causes errors in Laravel
GROUP BY The club GROUP BY accepts two types of information: text and whole. When an integer value is informed, you will be informing - implicitly - the position of the column that will be used in…
-
0
votes1
answer433
viewsA: Keyboard shortcut with javascript
Your code is correct. It is activating the element correctly, the fact that it is not changing the color (to inform the user) is that the class "active" is not being applied in the label of input…
-
0
votes1
answer230
viewsA: Drag & Drop at any position in the div
One of the ways to do this is by using the attribute position: absolute in his CSS. This way you can use a fixed value to position your element through the property left and top of CSS. The…
-
2
votes1
answer112
viewsA: Change chips default behavior materialize
To add chips with the space key, just add the one function to the method onkeyup. This way you can detect which keys the user pressed; if it is the space, just use the function addChip. Example: /*…
-
2
votes1
answer110
viewsA: File type input with split() function returns with comma
This happens because the String.split will return a array. In this case, the jQuery will use the function Array.implode before adding the value in input (since he accepts only string). To correct…
-
2
votes1
answer92
viewsA: How to list all xml for php
When you use simplexml_load_string or simplexml_load_file, an object of the type is returned SimpleXMLElement. With this object, you cannot capture a particular element with this code…
-
4
votes1
answer384
viewsA: How to change background color according to value
Just use a if or ternary operation and use the property element.style.backgroundColor. Example: /** * Captura os elementos */ const content = document.querySelector("#content") const count =…
-
1
votes1
answer32
viewsA: Time limit for each post
You can use two functions for this: ADDDATE or DATE_ADD to add dates or DATEDIFF to calculate the difference between dates. Structure and Data of Examples: CREATE TEMPORARY TABLE `postagem` ( `id`…
-
3
votes2
answers28
viewsA: Declare variable value in function call
Since you are using only one parameter of the Object, it is not necessary to pass it completely, just pass true or false for the function, for example: function clearSearch(clear = true) { if…
-
2
votes2
answers260
viewsA: Why does Vue.js lose formatting when adding dynamic items? Is it possible to fix this?
It’s not the problem of Vuejs, the problem is that the Bootstrap cannot "see" the new element, for this it is necessary to (re)start the Bootstrap Material Design every time you add a new element.…
-
1
votes1
answer168
viewsA: Form in stages, how to ignore some input and proceed?!
In function validateForm, just use y[i].required, thus only the input containing the attribute required, will be validated (whether it is empty or not). In HTML: <input placeholder="Empresa*"…
-
3
votes1
answer43
viewsA: How to insert an item before and outside another item?
The jQuery has some methods to add content before certain elements, two of them are: .prepend() and .before(). Prepend In this method the jQuery will capture the element #add-mesa-de-luz-button and…
-
4
votes3
answers10794
viewsA: store an array of objects in a Storage location with JS
It is necessary that you use a array to store values. To save to localStorage, just use the JSON.stringify. In the capture it is necessary to analyze (parse) the returned object, for this we can use…
-
2
votes1
answer984
viewsA: Take HTML elements from a url and send to a div
You can use the XMLHttpRequest or Fetch to make a request to get source code from the page. After that, just use document.createElement or DOMParser to be able to "convert" the returned source code…
javascriptanswered Valdeir Psr 10,804 -
0
votes1
answer80
viewsA: Change Javascript iterative select background color
Just use a repeat loop, for example: for, forEach, while etc.. Example with for..of: const selects = document.querySelectorAll('select'); for (let select of selects) {…
-
1
votes1
answer26
viewsA: Problem with HTML preview
You can use a iframe to do so. This way, if the user modifies the CSS, it will not compromise the main document. Follows basic code: Javascript: function preview(input) { const ta =…
javascriptanswered Valdeir Psr 10,804 -
4
votes1
answer1166
viewsA: Which Way to Recursively Remove Accented Characters from File Names
You can use the command iconv. This function will convert characters from one encoding to another. The command is simple. Contents of a file: iconv -f UTF8 -t ASCII//TRANSLIT < input.txt >…
-
0
votes1
answer41
viewsA: Clone text area values
It is necessary to assign the new value to the attribute value. Example: const ta = document.querySelector("#ta") const ta2 = document.querySelector("#ta2") function preview(input) { /* Captura o…
javascriptanswered Valdeir Psr 10,804 -
0
votes1
answer35
viewsA: What’s wrong with the jQuery code I wrote?
Turns out you’re creating a new event every time the scroll bar is used. Since the number of events created is high, then the code will be repeating the same process (to take the page to the top)…
jqueryanswered Valdeir Psr 10,804 -
1
votes1
answer31
viewsA: Compares selected input file size with PHP disk_free_space
You can do it. Just use element.files or $("input").prop("files"), with this you will have access to Metadata of the file (size, mimetype etc.). Commented example: /* Como o aqui não irá funcionar o…
-
0
votes1
answer242
viewsA: Block a button after displaying jquery validate message?
Use the methods invalidHandler and success of own jQuery Validate. The first runs when the user tries to send an invalid form; the second will run every time a field is correctly validated.…
-
0
votes3
answers359
viewsA: "Onclick" function that calls PHP function
Here is an alternative to AJAX, posted in another reply. It is not good practice to use location.href along with the code PHP. For redirects you can use the function header. PHP: $sql = "INSERT INTO…
-
0
votes1
answer94
viewsA: Take external json data, list, and save to webstorage
There are some errors in your code, for example item.id.nome. Follows updated and commented code. <!DOCTYPE hml> <html> <head> <title>Title of the document</title>…
-
1
votes2
answers1000
viewsA: Change Input color when typing x characters
Just use the event input in the Javascript. With it you can detect all field changes. Example with Javascript "Pure": /* Captura o campo */ const fieldMessage = document.querySelector("#message") /*…
-
0
votes1
answer43
viewsA: Put Transition effect on div which is added class as scroll
The transition does not work with the property display. In this case you can use visibility and opacity to create the effect. For this, just make the modifications below: a.container-msg-chat{…
-
1
votes2
answers32
viewsA: php fetch <p> content
Use the following code: preg_match_all("/<p[^>]*id=\"sinopse2\"[^>*]*>(.*)<\/p>/", $html, $output); var_dump($output); Explanation of the Regex:…
-
3
votes1
answer371
viewsA: Doubt in Toast.makeText(this, ...)
The mistake happens because this does not exist in static objects/methods, but there is another error in the code. Following explanation below. To use the Toast.makeText it is necessary to pass the…
-
1
votes1
answer375
viewsA: date + 2 working days
You can do it this way: SELECT DATE_ADD("2018-07-01", INTERVAL (IF(DAYOFWEEK("2018-07-01") = 5 OR DAYOFWEEK("2018-07-01") = 6, 4, IF(DAYOFWEEK("2018-07-01") = 7, 3, 2))) DAY); Comments on the code:…
-
1
votes2
answers327
viewsA: Increase +1 in database
In addition to the form already shown, you can also do with the following code: $con = mysqli_connect("localhost", "root", "asdasd", "dbb") or die("Failed to connect to MySQL: " .…
-
10
votes1
answer1549
viewsA: How to search for an exact word with the grep command
Use the option --word-regexp or simply -w, for example: ps aux | grep -w bc The above parameter will return only the line that contains the informed word (and not only a part of it) preceded by…
-
1
votes2
answers1203
viewsA: How to prevent the number being less than or equal to 0 in an input type number?
Just use the event input through the Javascript. Follows code and explanation: /* O evento input do DOM é disparado sincronicamente quando o valor de um elemento <input>, <select>, ou…
-
0
votes1
answer69
viewsA: Add values to Textview treatment
Use the class Decimalformat to format numeric values, with it you can set a pattern and then format it, for example: DecimalFormat df = new DecimalFormat("#,##0.00"); String formatted =…
androidanswered Valdeir Psr 10,804 -
1
votes2
answers57
viewsA: I want every time I click on the 'Armchair' function it changes color
If you have more than two colors, you can use an array to store the values and then change according to the amount of click. Commented example: /* Define as cores */ const cores = ["yellow",…
-
1
votes1
answer24
viewsA: PHP page connects to the database, loads but does not delete
How are you working with anchor (links with parameters) and not with form (<form>), you must use $_GET instead of $_POST, for example: $id = isset ($_GET['id']) ? $_GET['id'] : ''; Do not…