Posts by Yure Pereira • 3,971 points
117 posts
-
1
votes1
answer1187
viewsA: Compare 2 dates
You could do it as follows, using the native PHP Datetime class: <?php $vencimento = DateTime::createFromFormat('d/m/Y', '22/02/2018'); $hoje = new DateTime(); if ($hoje > $vencimento) { echo…
-
0
votes5
answers273
viewsA: Taking html class with PHP variable in javascript
You could try taking it this way: $(function() { var selects = $('[class^="selects2"]'); selects.each(function(index, element) { alert(element.className); }); }); <script…
-
3
votes3
answers430
viewsA: Replace part of a Java String
You can use a Hashmap to store all the professions and use the method already cited to create the desired String. As follows in the example below: Map<String, String> occupations = new…
javaanswered Yure Pereira 3,971 -
0
votes1
answer68
viewsQ: What is the most recommended and performative way to manipulate dates in PHP?
In PHP we can manipulate dates using functions such as date, strtotime, mktime etc. and from version 5.3 of it we can manipulate dates object-oriented with the classes Datetime, Dateinterval,…
-
1
votes1
answer156
viewsA: How to delete the last div added by DOM?
The error that occurs in your code is due to you using the identifier (Attribute ID) of the elements created with the same name, and the ID of an element must be unique and cannot be used in other…
-
1
votes1
answer117
viewsA: How to define the output format of an XML in PHP?
Do as follows below, using the option of LIBXML_NOEMPTYTAG as the second parameter in the method saveXML: <?php $dom = new DOMDocument( "1.0", "ISO-8859-15" ); $root =…
-
0
votes3
answers85
viewsA: How to hide and then show an article?
You can do it this way with pure Javascript: (function() { var detalhes = document.getElementsByClassName('detalhes'); //Esconde o elemento article. detalhes[0].style.display = 'none'; var lista =…
javascriptanswered Yure Pereira 3,971 -
4
votes3
answers1608
viewsA: Auto Load of classes in PHP
You can do as follows, first improving the readability of the code, using simpler names to make it easier to understand and using the normal syntax of if and foreach. Then using the function…
phpanswered Yure Pereira 3,971 -
4
votes2
answers559
viewsA: How to handle an empty string?
You can solve your problem as follows, simply by adding a parameter delimiting the maximum amount of results of the method split, thus s.split(",", 3). for(String s : result){ String pessoa[];…
-
0
votes1
answer97
viewsA: How do I make a variable become an object?
As follows: $this->load->model('Mod_login'); $get = $this->Mode_login->gettoken(); echo $get[0]->datta; The method result Codeigniter’s Active Record Class returns an array with the…
-
3
votes2
answers3961
viewsA: How to do a preg_replace with various conditions and changes?
You can do as follows abaico, passing two arrays as arguments to the function preg_replace, the first with substitution patterns and the second with substitution values: <?php $string = 'Lorem…
-
2
votes5
answers498
viewsA: Capture Enter in IE using jQuery
The problem that occurs in your code is that the function which not supported in older versions of Internet Explorer, only from version 9 of it. So to solve your problem, with a simple solution and…
-
0
votes2
answers1875
viewsA: Jquery mask does not work
The problem that occurs is due to you adding the mask when the page is initialized, but when this occurs there is still no element with the id="dia" loaded into the HTML document. So how are you…
-
6
votes2
answers39330
viewsA: How to make a vertical line
You can add vertical line with HTML and CSS as follows: .linha-vertical { height: 500px;/*Altura da linha*/ border-left: 2px solid;/* Adiciona borda esquerda na div como ser fosse uma linha.*/ }…
-
2
votes2
answers527
viewsA: Table with width 100% and Scroll
You can do as follows below, added the table within a div: .my-table { overflow-x: auto; } table.width { width: 100%; /* Optional */ border-collapse:collapse; white-space: nowrap; } td { border: 1px…
-
2
votes1
answer435
viewsA: Route results in 404 Not Found
Puts the . htaccess file as follows: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$…
-
2
votes0
answers203
viewsQ: What is the difference between function expression and function definition in relation to Hoisting in Javascript?
What is the difference between function expression (named or unspecified) and function definition in relation to Hoisting no Javascript? Named function expression syntax: var somar = function…
-
4
votes2
answers215
viewsA: How is the reading of sentences with comma in Javascript?
This is a technique of precedência de operador, and the name of that operator is operador de vírgula (comma operator) or also known as multiple assessment operator. It works as follows, it evaluates…
-
3
votes3
answers1458
viewsA: Javascript - Line break in file . txt
Here’s a full example of how you can do this using Ajax: var xhr = new XMLHttpRequest(); xhr.open('GET', 'arquivo.txt', true); xhr.responseType = 'text'; var texto = ''; xhr.onload = function () {…
-
37
votes5
answers7326
viewsQ: Is Javascript an Object-Oriented language?
Many say that it is not an object-oriented language, because it is not possible to define classes in it, until its version Ecmascript 5, but with the use of constructing functions and prototyping it…
-
10
votes1
answer2618
viewsA: How to use <address> tag, doubts?
It is not wrong to put only one email, as this element serves to insert contact information about your page when used globally within the element <body> or about an author in cases where he is…
-
1
votes1
answer664
viewsA: How to extend Ci_controller to more than one core?
You can do this simply by including the base controller file as follows, when using it: include_once(APPPATH.'core/Nome_Controller.php'); For example: <?php if ( ! defined('BASEPATH')) exit('No…
-
4
votes2
answers1714
viewsA: How to create a number generator from a Home number and a Final number?
You can do as follows below using this function randomNumber javascript: function randomNumber(min, max) { return Math.floor(((max + 1) - min) * Math.random() + min); } alert(randomNumber(85659,…
-
2
votes2
answers144
viewsA: How to acquire the value of the onclick() event
Apparently what you want done is that when the image that has been added is clicked, it is deleted. That maybe it’s like in the example below: function myFunction(src) { var newImg =…
-
3
votes1
answer83
viewsA: Are the scoped variables deleted even in Javascript?
In the Javascript there are two types of scope, which are global and local. Global scope is when you define a variable outside the code block of a function, so the variable is accessible to all the…
javascriptanswered Yure Pereira 3,971 -
13
votes4
answers48238
viewsA: How to convert a String to Int in Javascript?
As follows below using the native function parseInt of Javascript, you can convert a String for a Int: var number1 = parseInt('10'), number2 = parseInt('100'), result = number1 +…
-
0
votes2
answers12979
viewsA: How to apply scrollbar only to the tbody element in an HTML table?
To solve this problem I applied the following solution: First define the .table thead tr as a block element and in relative position: .table thead tr { display: block; position: relative; } Set a…
-
6
votes2
answers12979
viewsQ: How to apply scrollbar only to the tbody element in an HTML table?
How to apply the scrollbar (scrollbar) only in the element tbody, thus leaving the element caption and thead fixed on the table, without moving when the scrollbar moves. Below follows the HTML and…
-
1
votes1
answer258
viewsQ: What techniques can be used to authenticate in REST applications?
I’m developing an application Restful in PHP, I need to do an authentication mechanic on that system, so client applications can consume your data. What techniques can be used to authenticate…
-
4
votes3
answers6231
viewsQ: How to compare the structure of two SQL Server databases?
I need to compare the structure DDL of two databases, where one is the production bank and the other is the approval of a system. What tools can be used to do this?
-
0
votes3
answers134
viewsA: Give a value for radio input not selected
Both do as follows below using condition structure if one-line, to select radio input: <input type='radio' <?php if ($opcao == '1') echo 'checked'; ?> name='respostas[".$c."]'…
phpanswered Yure Pereira 3,971 -
0
votes2
answers106
viewsA: assign radio value found in sql - Codeigniter
A solution that you could apply, would be using a Boolean expression inside the radio, to define whether the radio will be checked or not, as follows in the example below, where it can work the…
-
0
votes2
answers216
viewsA: Menu Centralized
You can do as follows below: h1 { color:#00C; text-align: center; } body { padding:0px; margin:auto; max-width: auto; } #menu { width: 100%; height: 30px; background-color: #999; } #menu ul {…
-
1
votes1
answer208
viewsA: CSS selector changing value if it contains an element
A form using only css that could possibly solve your problem, serio the following solution below, using the selector css3 :empty, applying a particular css if the selected element has no child…
-
0
votes4
answers926
viewsA: How to use css align for tables
So much to do in the following ways below, using float: right; if you want to put your table on the right, and if you want to align your text on the right inside the table, use text-align: right;.…
-
4
votes2
answers3351
viewsQ: How do I create a Checkbox using the Html.Checkboxfor Helper for a Nullable field?
My field is as follows in my class: public bool? meuCampo { get; set; } And in my view it’s like this: @Html.CheckBoxFor(m => m.meuCampo) Only that way it’s not allowed, because I can’t…
-
1
votes2
answers334
viewsA: form read database
This is because the $Resp variable in your code is an array, which was returned by the function mysqli_fetch_row and when trying to print on the screen a Array, PHP prints a string 'Array', not what…
-
2
votes2
answers182
viewsA: Insert multiple values in component
You can do as follows below, using a variable data with the values of select, and if you want to select more than one item at a time in the dropdown and just add the attribute multiple="multiple" in…
-
0
votes2
answers918
viewsA: Use id for auto-no-increment insertion
In Codeigniter there is the method $this->db->insert() that returns the ID of the last record inserted in the database. This method returns exactly the last ID inserted as it uses the function…
-
1
votes3
answers603
viewsA: Problem sorting an array with Sort()
You can do as follows to order correctly by passing a function of callback as a parameter for the function sort: var a = [44,7,5,6,4,2,1]; a.sort(function(a, b) { return a - b; });…
-
1
votes3
answers105
viewsA: doubts related to site style
Do as follows below, just because you have not made your HTML and CSS available, you will probably need to make a few changes. .login-page { background-image: url('nature.jpg'); background-repeat:…
-
2
votes1
answer278
viewsA: How to create a json from my object?
You can do this as follows below, in the example I am using the native PHP function json_encode that transforms an object to the format json, but in case you want to do the reverse, you can also use…
-
1
votes1
answer491
viewsQ: What are the free libraries options for ASP.NET MVC PDF generation?
I am currently using the selectpdf library, but it has some restrictions on its free version, I would like to know other options that I can use.
-
0
votes2
answers655
viewsA: How to Add a Locksmith to the keypress event on all pure javascript inputs?
You could do it this way: /** * * @param el Object element a ser adicionado o evento * @param func Function função a ser adicionada */ function addKeypress(el, func) { if (el.addEventListener) {…
javascriptanswered Yure Pereira 3,971 -
1
votes2
answers45
viewsA: Hide a certain amount of items
You can do this by using the jQuery toggle function and lt(n) selector to select the first 5 items: $(function() { var codes = $('.code'); var first5 = $('.code:lt(5)'); codes.toggle();…
jqueryanswered Yure Pereira 3,971 -
1
votes5
answers7569
viewsA: How to delete COOKIES in PHP?
Do it this way: <?php unset($_COOKIE['nome_cookie']); setcookie('nome_cookie', null, -1, '/');
-
2
votes2
answers1198
viewsA: Check for capitalized words
Give to do as follows with strtoupper function: <?php $palavra = 'PALAVRA1'; if (strtoupper($palavra) == $palavra) {//TRUE echo 'Verdadeiro'; } $palavra = 'pALaVRA1'; if (strtoupper($palavra) !=…
phpanswered Yure Pereira 3,971 -
12
votes1
answer6364
viewsQ: What are the advantages of using object-oriented databases?
What are the advantages and disadvantages of using object-oriented databases in relation to relational databases? What are the most commonly used object-oriented databases?
-
0
votes2
answers10563
viewsA: Format/mask CPF in Mysql or PDO
You can do this by creating a FUNCTION in your database and using it in your SELECT, as follows: DELIMITER // CREATE FUNCTION format_cpf(cpf VARCHAR(11)) RETURNS VARCHAR(14) BEGIN RETURN CONCAT(…
-
1
votes1
answer2983
viewsA: How to mark checkbox?
If you refer to a checkbox, you can do as follows: HTML example: <form action=""> <input type="checkbox" id="my_checkbox" value="Bike">Checkbox<br> </form> Javascript: var…
javascriptanswered Yure Pereira 3,971