Posts by Ricardo Pontual • 21,129 points
751 posts
-
0
votes1
answer194
viewsA: Create string array of textarea using n as separator
Already answered your own question: use the split to separate lines. What was missing from your code was to iterate over the array, with for or foreach to, as you asked, make a call ajax for each…
-
0
votes1
answer132
viewsA: Doubt in Javascript + Sqlite3, return of Select
Only playing the values in the array will not have allow you to group each row that returns from the bank, and read with the names you need (Name, Category, etc). You need to create an object and…
-
1
votes1
answer675
viewsA: What is the difference between JOIN and UNION in SQL?
JOIN is used to link tables through a common value. UNION is used to join two or more queries and bring the whole result together Yes, the results are quite different, the goal of one is to relate…
-
2
votes2
answers295
viewsA: Proper use of while to validate data entry
That "supposed" block while that you mentioned does absolutely nothing, it would be like using parentheses like this: int x = 1 + 1; // ou int x = (1 + 1); Note that while is part of the command do,…
-
2
votes2
answers103
viewsA: how to check if an image is online
An image, as well as other web resources (audio, video, etc.) is loaded via a request. To check if they exist, or if they are available, you can make a request to url of the resource and test…
javascriptanswered Ricardo Pontual 21,129 -
1
votes1
answer59
viewsA: How to call a c# script inside a python script
Yes, when you say "execution of C#" that is to say "a program written in C#", correct? After all, C# is only one language. An executable program (which can be written in any other language) can be…
-
2
votes1
answer58
viewsA: Problem making a method call in class constructor (javascript)
As @Now-Now commented, if you are accessing a member of your own class, you should use this. To better understand, I’ll even use your example, in the method setTitulo. Supposedly by name, he should…
-
2
votes1
answer37
viewsA: Doubt Select in Mysql
Just do the Join twice, one calling idPrefeito and another idVice, using different aliases for each: SELECT cidade.nome, ppref.nome as Prefeito, pvice.nome AS Vice FROM cidade JOIN pessoa ppref ON…
-
0
votes1
answer446
viewsA: How to change default background-color of . active Bootstrap 4
You need to change the style of the class dropdown. Nestled to it, the active button class is .dropdown-item .active The css looks like this: .dropdown-item.active, .dropdown-item:active {…
-
0
votes3
answers588
viewsA: Recover $_SESSION with Ajax
Session is a value that should be used on the server side, handling it in the frontend is not a good practice, it is not safe as it is much easier to have access by other people. If you’re…
-
3
votes1
answer82
viewsA: Why is the bitwise operator returning me 0 in this case?
There are several misconceptions in your question: 1) the binary representation of 1 is not 00110001, but yes 00000001, even for 2 00000010), needs to review how the binary base works and how to…
javascriptanswered Ricardo Pontual 21,129 -
2
votes2
answers701
viewsA: Update table of duplicate records with conditions
For this you need a sub-query or a Join to resolve, because the records to be changed are those that appear more than once, and with the date different from the maximum. These records could be…
-
10
votes2
answers197
viewsQ: When to use Lazy<> from C#
Where is a good scenario to use the initializer Lazy<> of the C#? I ask this because I understand the concept behind the Lazy loading (delay the instance of an object to only when it is…
-
1
votes1
answer87
viewsA: Regular Expression for Secure Password
Your expression looks good, but replace the =. for =.?*. In addition, special characters are missing in the last group, and it is not in the question, but it is also limiting to a minimum of 8…
-
0
votes1
answer65
viewsA: Count without returning 0 in Presto
The problem with the aggregation functions (COUNT, SUM, AVG, etc) is that they do not compute null values. When we have values NULL in the column itself or because of a LEFT JOIN or RIGHT JOIN for…
sqlanswered Ricardo Pontual 21,129 -
1
votes2
answers322
viewsA: Insert a Count(*) value into a variable in Postgresql
Invert the variable assignment with the into, thus: select into consultaReserva count(*) from reserva_quarto Also, your variable does not have the @ in the name (this is used in sql-server), so you…
-
0
votes2
answers133
viewsA: How I search properties within a td / tr using only js
To read the contents of a td, you can use the property innerText: var tabela = document.querySelector(".infraTable"); var tds = tabela.getElementsByTagName("td"); for (var i=0; i<tds.length; i++)…
-
1
votes1
answer33
viewsA: Unique selection of Radiobutton
To choose from several RadioButton, they need to have the same name in html (for example name="parimpar") How are you using the control of asp-net, use the property GroupName, for example…
-
0
votes2
answers900
viewsA: Problem inserting text into a Javascript div
Probably not waiting for the document to be ready and loaded, and already trying to get the element and exchange its content, I try to do this for example in the event onload of the body: var…
-
9
votes4
answers1090
viewsA: How to create an array filled with values from 0 to n in javascript?
Simpler doesn’t necessarily mean clearer, your method seems good to me, but if you want something simpler, you can use the Array., which basically returns an array and executes a map inside, which…
-
8
votes2
answers568
viewsA: "Alert", "confirm" and "prompt" are considered bad practices?
They are not bad practices, even because they are still in the language, I believe that we can say otherwise: "do not use Alert, confirm and prompt, because there are currently other ways to do that…
-
2
votes1
answer20
viewsA: Javascript button to change image
First you need to understand that by passing parameters to a function, in your case the Function alterarImagem, the parameters must be valid varietal names, and "flower.jpeg" is not a valid name (I…
javascriptanswered Ricardo Pontual 21,129 -
4
votes2
answers881
viewsA: .addeventlistener is not a Function
getElementsByTagName returns an array of objects, to use the addEventListener it needs to be a single object, so this error happens. Since it is an array, you can take the first element and select…
-
2
votes2
answers74
viewsA: Create methods in classes to manipulate fields
The method with the same class name is builder class, which is the method executed when constructing a class object, using the new, for example Cliente cli = new Cliente(). In your example, the…
-
3
votes1
answer557
viewsA: How to add Primary key to an existing column of an already populated table
Yes you do, the command is a ALTER TABLE: ALTER TABLE nome-da-tablea ADD PRIMARY KEY (nome-do-campo) Now, the contents of the field must respect the rules of a Primary key (quoted from the link…
sql-serveranswered Ricardo Pontual 21,129 -
1
votes1
answer96
viewsA: Multiple COUNT() in a single query
This happens because the COUNT does not count null values, you need a treatment: SELECT dataAcesso, COUNT( idAcesso ) AS totalAcessos, COUNT( contato ) AS totalContatos, COUNT( NULLIF(contato, 1) )…
-
1
votes1
answer176
viewsA: Inserting a PROCEDURE in query() in PHP
Not being made the correct bind of the parameters, can do so: // declara o sql $sql = "CALL CadastrarFuncionario(@nomefun, @cargofun, @nascimentofun, @cpfun, @rgfun, @estadofun, @salariofun);"; //…
-
1
votes2
answers41
viewsA: Change the value of a field when a condition is true
You can use the CASE, which has the following format: CASE condicao THEN valor, that in your case would look like this: SELECT PA.EMPRESA, PA.CONTRATO, PA.PARCELA, PA.SITUACAO, PA.PMT, PA.IOF,…
-
4
votes2
answers650
viewsA: What is Separation of Interests (Soc - Separation of Concerns)?
Introducing To understand what the Separation of Responsibilities means, let’s see what the first principle of S.O.L.I.D is.: Sigle Responsability Principle (SRP), or Single Liability Principle.…
-
3
votes1
answer109
viewsA: Timer in Javascript does not start
Your code has two basic problems: Using the same variable to control 3 different timeouts; He’s making the call to setInterval stopping parameters in a way that doesn’t work. For the first item, you…
-
4
votes3
answers67
viewsA: Knowing which element triggered the event
Can use $(this).hasClass("class1"). The $(this) takes the element that triggered the event, and the hasClass checks which class it has. $('.class1, .class2').click(function() { var class1 =…
-
0
votes1
answer26
viewsA: Create an event to delete from a time
You can use the INTERVAL to calculate the 5 minutes in the query: DELETE FROM redefinirsenha WHERE `Data` < NOW() - INTERVAL 5 MINUTE;
-
3
votes1
answer79
viewsA: Convert percentage to real in the input Rage slider Html5
This is much more a mathematical problem than a computer problem, which can be solved with the following calculation: x = valorMinimo + porcentagem/100 * (valorMaximo-valorMinimo); For example,…
-
0
votes1
answer196
viewsA: How to place an AUTOINCREMENT ID?
When you create a table on sqlite, unless the option is used WITHOUT ROWID, always a column named rowid that is autoincrement, then the value of that column already serves as that id you need, just…
-
3
votes3
answers253
viewsA: Cannot implicitly convert "decimal" type to "int" in C#function code
How to properly perform this conversion? Simply convert from decimal for int: return Decimal.ToInt32(media);
-
2
votes3
answers114
viewsA: Sequence code of numbers returns the incorrect sum of numbers C#
Before the do need to add the first number, otherwise it is lost when executing the ReadLine() within the loop: numero = Convert.ToInt32(Console.ReadLine()); somanumero += numero; do { .... resto do…
c#answered Ricardo Pontual 21,129 -
0
votes2
answers71
viewsA: Doubt switch structure Javascript
This happens because if you put two or more case without a break it would be like "if it’s 0, or 1, or 2, or 3...." that is, like a sequence of values with "or". As if it were a command if thus: if…
javascriptanswered Ricardo Pontual 21,129 -
2
votes1
answer28
viewsA: CSS class application after click on LABEL and also on CHECKBOX
Just add another selector to the input, and click to fetch the label. For that use parent(), to get to the li and then something like find('label') to find the element and apply the style, thus:…
-
3
votes1
answer174
viewsA: Is it possible to identify the source database of a stored SQL database?
Yes it is possible. Basically all objects in the database are in tables like sys.tables, sys.procedures and sys.objects, just select them, but these tables exist in each database, so you would need…
-
0
votes1
answer90
viewsA: Does the Pdostatement bindValue() not work with the table name?
No, the substitution of values with bindValue does not work with all parts of the command, such as the command itself (select, update, etc.), nor with field or table names, works with values in the…
-
0
votes1
answer410
viewsA: Radio type input check with jQuery
You cannot have two elements with the same ID in the form. Your radio options must have the same name but not the same ID. Changing this, it is possible to take the value of the radio by name, so:…
jqueryanswered Ricardo Pontual 21,129 -
4
votes1
answer217
viewsA: Why can I cancel the onkeydown event but can’t cancel the onkeyup?
It’s not that the keyup can not be canceled, but who is dealing that has been pressed a key is the keydown, since it did not cancel the keydown this can no longer be done, and what was typed is…
-
1
votes1
answer490
viewsA: Convert Varchar to Int
But nome_mun is varchar and is the name of the municipality right? Can not equal min(populacao), which is numerical and has no relation to the name, so you need to return the nome_mun in the…
-
4
votes3
answers270
viewsA: How to open a new html file in the same tab?
You can also change the location using Location.replace location.replace("nova url"); function replace() { location.replace("https://answall.com", "_self"); } <button id="replace"…
-
0
votes2
answers310
viewsA: How to take the "style" of an element inside a div
You can use the window.getComputedStyle to get all styles of the element h1, and then the font-size: var h1 = document.getElementById('teste'); var fontSize = window.getComputedStyle(h1,…
-
1
votes1
answer123
viewsA: Cordova in Visual Studio - Compilation Error. Does not generate apk
As the message shows, this happens because the java when executing some command. This happens with the installation of Apache Cordova in the Visual Studio because many things are installed beyond…
-
1
votes1
answer61
viewsA: Search json tags with REGEXP ignoring accents
Unfortunately you can’t. REGEXP uses the byte of the character, its code, which differentiates accented and not accented characters, since each one has a different code. I already had this problem,…
-
2
votes3
answers63
viewsA: Sort table by date
Why didn’t you keep the DESC for the two camps? It is ordering by "asc date" and only "desc time". Do so: ORDER BY `transaction_DATE` DESC, `transaction_HOUR` DESC…
-
3
votes2
answers177
viewsA: Run an SQL script in transaction without it blocking other scripts accessing the same table
What you want to do is something against the nature of a transaction. If you do not want a more time consuming line, table, page, etc lock, then you should not execute a transaction, just run the…
-
1
votes2
answers116
viewsA: ORDER BY orders by the first house and not by the number itself
As @Leandro commented, if you want to sort numerically, it would be better to change the field type to numeric (integer for example). An alternative solution, as long as the table is not too large,…