Posts by Victor Carnaval • 2,430 points
111 posts
-
2
votes2
answers94
viewsA: jQuery selecting the element itself
$('#add_phone').bind('click', function() { const $input = $('[camp=phone]').find('input'); const $clone = $input.clone(); $('#add_phone_div').append($clone); }); <script…
-
0
votes2
answers54
viewsA: for/if PHP omitting element
Douglas, I updated the code you posted with more readability to make it easy to identify the error. $depByPage = ''; foreach ($servidores as $value => $servidor) { $servidor->ferias =…
-
-2
votes1
answer48
viewsQ: Creating a slider with Jquery
Talk community, all right?! I’m creating a slider using Jquery and I’m not getting any further. In the example I created I can’t change the images by clicking on the bottom right menu. Which code…
-
0
votes1
answer202
viewsA: Datatables Warning(table id = 'example'): cannot reinitialise data table
The log itself is displaying the error "cannot reinitialise data table", that is, you cannot reboot the DataTable. Start only once and make all necessary settings as in the following example.…
-
0
votes2
answers96
viewsA: Do you doubt how to store the ID of a record brought from the bank for later use in PHP?
You can use PHP sessions to store each clicked item. After obtaining all the database data, create the session variable responsible for storing all the clicked items. //... $row =…
-
4
votes4
answers1262
viewsA: Take array value
You are using a multidimensional array. If the two arrays have the same amount of items, you can use the loop as follows. for ($i = 0; $i < count($avariasIni[0]); $i++) { echo $avariasIni[0][$i]…
phpanswered Victor Carnaval 2,430 -
0
votes1
answer24
viewsQ: How to obtain the name of the protected properties of an object without the asterisks?
It is possible to obtain only the name of the protected properties of an object without the asterisk symbol (*). class Person { protected $name; protected $age; } $person = new Person();…
phpasked Victor Carnaval 2,430 -
1
votes1
answer97
viewsA: Record logout time in the session table
Use the same session variable to store and retrieve the record in the database. EDIT: $queries = "INSERT INTO raddb.sessoes (iduser, user, data, ip) VALUES ('$teste1', '$teste2', '$data_hora',…
-
3
votes2
answers44
viewsA: How to Improve/Optimize this code?
I used the counter loop to concatenate with the string that represents the key of the received request array. $user = $_SESSION['nome_usuario']; $data = date('Y-m-d H:i:s'); $lotes =…
-
3
votes1
answer61
viewsQ: Why do I need to add a parenthesis under multiple conditions of a ternary operator?
Let’s start from the following values: $foo = 1; $bar = 1; As the extra condition placed on else without parentheses, the result does not match the intention of the operator: echo ($foo &&…
-
1
votes2
answers56
viewsA: Syntax error when using . val() in a JSON
I’m using it properly? Not. The method getJSON reads the JSON file and transforms it into an object or array (array) depending on the file structure, which in its case is an array of objects. So to…
jqueryanswered Victor Carnaval 2,430 -
1
votes1
answer52
viewsQ: How to group records per day using Unix Timestamp?
I would like to group the results by days that belong to the period defined in the query. SELECT count(*) FROM historico WHERE contato_id IN (19, 45) AND createdAt BETWEEN 1556668800 AND 155936879;…
mysqlasked Victor Carnaval 2,430 -
0
votes1
answer150
viewsQ: How to add an array with dynamic values in an object with dynamic properties?
How best to create and populate an array dynamically and insert it into a dynamic property of an object? We can use the following scenario: $(function() { const products = {}; const items =…
-
0
votes2
answers136
viewsA: I can’t get information from my API via android app
I believe you are not being able to save because the array you are transforming into json is a multidimensional array. So it generates the indexes in your JSON that I believe is unnecessary. Make…
-
1
votes4
answers109
viewsA: Using the existing key_exists array
To search for a given key of a multidimensional array it is necessary to use the recursion and function array_key_exists doesn’t do that. function array_key_exists_recursive($needle, array $array) {…
phpanswered Victor Carnaval 2,430 -
0
votes2
answers464
viewsA: How to Use Masks in Ajax
As we can see below, the mask is normally added to the input value. $(function() { $('.input-cpf').inputmask({ mask: "999.999.999-99" }); $('.input-cpf').keypress(function() {…
-
0
votes1
answer73
viewsA: Load Json data via Ajax
As you are using Jquery I will leave a solution using the Jquery loop itself and selecting the correct elements. <script> $(function() { carregarclientes(); function carregarclientes() {…
-
1
votes1
answer351
viewsA: Change in checkbox is not working
In your Jquery selector the element is filtered form with the attribute name=rlManejo. Just add the tag form before the checkbox element. $(function() { $('form[name="rlManejo"]…
-
4
votes3
answers3540
viewsA: How to receive an array and return another
Welcome to the community and to the vast world of programming. Follow the solution with explanations: var numeros = [1, 2, 0, -1]; //O Array de números fornecido pela questão maisMenos(numeros);…
-
1
votes1
answer171
viewsA: How do callbacks and anonymous functions work in PHP?
As anonymous functions PHP works similarly as function expressions (Function Expression) javascript. To anonymous function is usually used as a callback but is not restricted to this, it can also be…
-
0
votes2
answers809
viewsA: send url with parameters in the Whatsapp api
Try concatenating the string using the .. $link = "clique neste link para validar sua conta site.com.br/usuario.php?id=" . $id; If the error persists, run the function echo to check that the string…
-
0
votes2
answers1571
viewsA: Receive text typed in input text, put in variable and apply in link
Just manipulate the event submit of the form and make the necessary amendments. $(function() { $('#send-message-whatsapp').on('click', 'button', function(e) { e.preventDefault(); const $form =…
-
0
votes1
answer825
viewsA: Jquery onkeypress ENTER
I created a table to exemplify the Jquery code I adapted. I believe it works for your case only remaining to change the selector for your scenario. /* Usamos $(document).ready(...) ou $(...) para…
-
0
votes2
answers134
viewsA: I cannot send JSON array to PHP page
As you are sending information to the server, use the correct HTTP verbs for the request which in your case is the verb POST. In addition to specifying the HTTP verb, you need to "tell" the server…
-
1
votes2
answers166
viewsA: form-check-input (check if no option has been selected)
Add the event of click directly at the checkbox. $('input:checkbox').click(function() { $('input:checkbox').not(this).prop('checked', false); if ($(this).is(':checked')) {…
-
0
votes3
answers52
viewsA: Running the POST before onclick
Validation may even occur but the default event of the form is to perform the request. You can use the method preventDefault to cancel the default event and perform the necessary manipulations.…
-
2
votes1
answer295
viewsA: Move element from one div to another without changing the state
You can use the method children to obtain all child elements of the parent element and the appendChild to add the elements to the new parent element. function mover() { origem =…
javascriptanswered Victor Carnaval 2,430 -
1
votes1
answer55
viewsA: How to make the button occupy all the height and width of its parent element?
You can add the style directly to HTML, or create a class for it. I’ll leave the two forms. funcionarios += '<td style="text-align: center; padding: 0px"><a style="width: 100%; height:…
-
1
votes2
answers443
viewsA: PHP email message in UTF-8
You need to add two headers below the variable $headers so that your email is sent in the correct way. $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" .…
-
4
votes1
answer44
viewsA: Problem with select in my controller
The function all() is to return a collection of values obtained from your database. So when you declare Postagens::all(), will be returned a collection of all existing records in the configured…
laravelanswered Victor Carnaval 2,430 -
2
votes3
answers75
viewsA: Definition of "arrows" in PHP
The PHP array’s key statements are optional. $array = ["foo", "bar"]; echo $array[0]; echo $array[1]; //Saídas "foo" "bar" If keys are declared, access to their values shall be made through the…
-
0
votes1
answer51
viewsA: charset does not work
Use the Html.Raw() to pass the string without Razor encoding. <script type="text/javascript" charset="utf-8"> $(document).ready(function () { alert("@Html.Raw(ViewBag.Erro)"; });…
-
0
votes1
answer28
viewsA: getelementsbytagname is returning wrong values
Enter your javascript code before closing the tag </body> to ensure that all HTML content has been loaded. Also, use the event onload to ensure that javascript runs after loading.…
-
1
votes2
answers61
viewsA: Problems with the return of $_POST values
Concatenate the content of the email in a more readable way. $mail->Body = nl2br("Nome: $con_name\n" ."Email: $con_email\n" ."Telefone: $con_telefone\n" ."Mensagem: $con_message\n" ."Post: " .…
-
0
votes4
answers2698
viewsA: How to pass php array to javascript
Use the function json_encode to convert a PHP value into a JSON representation. It can be any PHP value, except Resource. $json = []; while ($row=$stmt->fetch(PDO::FETCH_ASSOC)) { extract($row);…
-
2
votes2
answers105
viewsA: How to recover an input value by button
For your scenario use the Jquery function Prev(). This function returns the previous sibling element. function getValor(button) { const $button = $(button); //Convertendo objeto JS para objeto…
javascriptanswered Victor Carnaval 2,430 -
2
votes1
answer353
viewsA: Help to animate Back to top button. Javascript or Jquery
Use the function scrollTop Jquery and check that the returned value is greater than the desired number of pixels. $(document).ready(function() { $('#icon-smoothscroll-top').hide(); //Esconder o…
-
0
votes1
answer23
viewsA: I have a bug in my Symphony Controller Replay
Your validation is not working because the function count also counts empty elements of an array. $array = array("" => ""); echo count($array); // Saída: 1 You can improve your validation in two…
-
0
votes1
answer44
viewsA: Javascript help | Rename paragraph
Keep in mind that user entries are provided by the element input. Starting from this principle we can follow the steps below: Create the element input when the user clicks on the paragraph. Get the…
-
1
votes2
answers565
viewsA: Get Header information, javascript
Using the object XMLHttpRequest javascript itself, would be as follows: const xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { console.log(this.status); //Status Code…
-
1
votes3
answers98
viewsA: How to select a specific ul with jquery
You can use the method first() of Jquery where this will return the first element of the collection. $('.menu-expand').click(function() {…
-
5
votes2
answers914
viewsA: How does larger and smaller Javascript string checking work?
When there is a comparison '15000' > '100000', imagine that alphabetically the value 15000 is greater than 100000. As if it were a classroom call list in which names are ordered alphabetically,…
-
0
votes2
answers148
viewsA: Increase color hue
Using the filter brightness I got the following result. const dark = document.getElementById("dark"); dark.addEventListener("click", function() { let div = document.createElement("div");…
-
0
votes2
answers30
viewsA: How do I make this list in the image
How cool that you are venturing into this area of web development. What you are wanting to do is an import of a file css to your file html. Suppose you created a project called shop and represented…
htmlanswered Victor Carnaval 2,430 -
0
votes1
answer45
viewsA: PHP - Not checking all elseif’s at the same time
Ideally, you use logical structures to identify incorrect results. You have no limit to uses for if and elseif but this impairs the readability of your code. To make the code more readable, you can…
-
0
votes2
answers236
viewsA: Handle data received by AJAX
AJAX has the main purpose of making requests without the need to reload the page, that is, the values returned from the server after the request will be handled by the client without the need for…
-
1
votes2
answers37
viewsA: Change a class that is inside an id with Javascript
How you want to change the text content of the element h3, you can use a method of the object itself document to search for any HTML element within the selected div ("nav_menu-5"). As the text is in…
-
0
votes1
answer136
viewsA: What is the difference between int and variable with php casting?
To solve this problem and bring more security to your code, use Prepared statements. function buscar_informacoes($conexao, $codigo) { if ($conexao->connect_errno) { die('Could not connect: ' .…
-
1
votes1
answer40
viewsA: Unexpected '[', how to resolve?
If the PHP version is less than 5.4, the short array statement will not work, as this feature was added in version 5.4.0. In addition, assigning a value to an array key must be done using the symbol…
phpanswered Victor Carnaval 2,430 -
3
votes4
answers839
viewsA: Retrieve data from the logged-in user to use as the sender of the email in Laravel
To send the email using a dynamic sender, you need to use the helper config Laravel to change settings at runtime. Configuration - Laravel $email = Auth::user()->email; $username =…