Posts by André Ribeiro • 5,137 points
125 posts
-
0
votes2
answers107
viewsA: Angular component is rendered several at a time, but was only asked to do this once
You put <app-servers>, which is the component selector ServersComponent, within your own template. This creates an infinite recursion, because every time app-servers is rendered, it ends up…
angularanswered André Ribeiro 5,137 -
0
votes1
answer253
viewsA: ion-select load application with an option already selected in Storage
How are you using [(ngModel)]="selectddi", the option selected by default will be the same where the attribute value of ion-option is equal to the content of selectddi To put the last item in the…
ionic3answered André Ribeiro 5,137 -
1
votes1
answer60
viewsA: Count specific character amount in a range
You can use the following formula: =SUMPRODUCT(LEN(A1:A7)-LEN(SUBSTITUTE(A1:A7;"V";""))) Where: A1:A7 = Sash "V" = Desired character How it works? LEN(SUBSTITUTE(A1:A7;"V";"")) removes all…
-
5
votes1
answer792
viewsA: How does the system of voting and rating by stars work?
You get this result by calculating the weighted average of the values. Example: Dice: 5 estrelas: 733 votos 4 estrelas: 187 votos 3 estrelas: 102 votos 2 estrelas: 45 votos 1 estrela: 100 votos…
-
3
votes1
answer108
viewsA: Regex does not work on Chrome
The problem is that Chrome adds C:\fakepath\ before the file name. A solution that works in both browsers is to directly access the property files of input: $(document).on('change',…
-
5
votes3
answers1139
viewsA: Organize alphabetically with indicative header, json
You can sort the objects in the array and then iterate over them by taking the first letter of each name to use as a category to group the items in alphabetical order. The example below sorts the…
-
4
votes2
answers2842
viewsA: Accept only multiples of X in input
You can use HTML5 validation with a input of the kind number which already automatically validates the field and does not let the user submit the form if the entered value is not numerical. Using…
jqueryanswered André Ribeiro 5,137 -
4
votes2
answers469
viewsA: Replace all after first white space
You can use a regular expression in the replace: var phr = 'stirred up'; phr = phr.replace(/\s.*/, '') // phr agora = "stirred" The \s takes the first space and .* takes all the remaining characters…
javascriptanswered André Ribeiro 5,137 -
1
votes1
answer316
viewsA: How can I change with event click the menu of an item?
Since the arrow is inside the same submenu element, you can restrict the search to the parent of the arrow itself using find. Thus the slideToggle will be executed only on the class elements…
-
5
votes3
answers1994
viewsA: How to count characters from a Java reference?
Another alternative by using indexOf(): String str = "123456789.123456789"; // Como o índice da string começa em 0, indexOf retornará exatamente o tamanho da primeira parte. int t1 =…
-
5
votes3
answers19969
viewsA: Take the value of select
You can take the value of the selected item from the is using the function .val() on its own select. See working: $(function(){ $('button').click(function(){ alert($('#sel_mes').val()); }); });…
-
3
votes2
answers6243
viewsA: How to make a CSS background gradient (gradient)?
This tool (Ultimate CSS Gradient Color Generator) is a hand in the wheel when generating these gradients. The code it generates is compatible with several browsers. An example of the code generated…
-
6
votes1
answer20100
viewsA: change span color when mouse on li
You went the right way, but you put the :hover in the wrong place. To change the style of span (child) when passing the mouse on li (parent), the css should look like this: .menu li:hover span {…
cssanswered André Ribeiro 5,137 -
0
votes2
answers165
viewsA: How to make the user system banned
Just check the column value banned right after the query that picks up user information: if($data['banned'] == 1) { // usuário banido! faça alguma coisa } else { // usuário não foi banido. faça…
phpanswered André Ribeiro 5,137 -
3
votes2
answers1749
viewsA: Turn string into number
You can use the function parseInt to turn the string into an integer or parseFloat, if the value is a number with decimal places. parseint: var total = parseInt($("#total").attr('value')) + 1;…
-
2
votes3
answers12476
viewsA: Display data in a foreach table
You don’t need to use foreach to generate this table. You can do it like this: <?php function calculaAprovacao($notas) { // "resultados" retornará um array contendo "Aprovado" ou "Reprovado" //…
-
4
votes3
answers1348
viewsA: Problems with "or" in C++
The logical operator OR in C++ is ||. if(z == x || y == z || x == y) { cout << "\nErro. Os valores devem ser diferentes. Tente novamente: \n" << endl; } You are also adding one ; after…
-
1
votes2
answers78
viewsA: Update photo counter instantly
As I explained in another answer, the attribute onclick cannot be used this way. All you need to do is run the update each time the script showing the product is loaded. This way at each view the…
phpanswered André Ribeiro 5,137 -
7
votes1
answer11995
viewsA: Keep checkbox selected by default
To leave the checkbox marked as by default, just add the attribute checked to the element. Example: <form name=myform> <input type="checkbox" name=mybox value="1" checked>Trocar a água…
-
5
votes1
answer71
viewsA: Link and query problems
That’s not how it works. The onclick is an attribute of HTML running a Javascript code on the side of client. When you call 3 times $sql = ..., is actually running PHP code from the server and…
phpanswered André Ribeiro 5,137 -
5
votes2
answers1861
viewsA: How to refresh page and not send duplicate data to PHP database?
One solution is to make a redirect right after entering the information in the bank. Even if the user refreshes the page the POST sent before will not be resubmitted by the browser. Example:…
-
1
votes1
answer67
viewsA: Approve wordpress comments via email
You can add hook in wp_insert_comment to be notified each time a new commentary is added to the system and send the email to the site administrator with the links "approve", "disapprove" and "spam".…
-
3
votes3
answers995
viewsA: Disable all Dropdownlist Options s less what is selected
You can also use the function .not() with the selector :selected and reduce the code to one line. Example: $('#opcoes option').not(':selected').prop('disabled', true) <script…
-
6
votes7
answers1682
viewsA: Make the class builder private?
According to MSDN documentation: A private constructor is a special instance constructor. It is generally used in classes that contain only static members. If a class has one or more private…
-
7
votes1
answer20585
viewsA: How to get current user location through the google maps API?
You can use the method getCurrentPosition() of the object Geolocation to pick up the user’s current location. Example based on your code: var geocoder; var map; var marker; function initialize() {…
-
2
votes1
answer885
viewsA: Apply mask to dynamic fields generated after page onload
You are applying the plugin like this: $('.money').priceFormat({ prefix: 'R$ ', centsSeparator: ',', thousandsSeparator: '.', centsLimit: 2, limit: 14, }); This snippet will only run once and will…
-
2
votes1
answer198
viewsA: Fancybox keep arrow back and next always visible
You can add this to your css: .fancybox-next span { left: auto; right: 20px; } .fancybox-prev span { left: 20px; } Source…
-
1
votes2
answers114
viewsA: How to get a Date String?
If your goal is simply to validate you can use the class Simpledateformat to try to analyze the date. SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy"); // !! Importante !! lenient = false…
-
3
votes1
answer274
viewsA: Android Api for PDF file creation
You can use the package classes android.graphics.pdf which are available from the API LEVEL 19 (Android 4.4). Example taken from the documentation: // cria um novo documento PdfDocument document =…
-
4
votes1
answer629
viewsA: Make a negation filter in ng-repeat
So that the filter is of negation to ! needs to be within string passed to the filter. Instead of: !'00777' Must be: '!00777' If you have a variable or function and want to deny the result of the…
-
14
votes1
answer2041
viewsA: SQL LIMIT parameterized in PHP with PDO
The problem is that the LIMIT and OFFSET variables are being passed as PARAM_STR and this causes the PDO to add apostrophes in the numbers, generating a syntax error. To solve just use bindParam to…
-
4
votes1
answer47
viewsA: Ajax returns own code and executes
The problem is you added this require: require "ajax.js"; PHP tries to interpret the contents of this file, but as there is no tag <?php it prints everything as if it were pure HTML. JS files…
-
5
votes1
answer2775
viewsA: How to return the weather forecast via the prediction API dotempo.org?
The problem is that you are trying to make a cross-Omain request via ajax, which is not allowed due to Policy of the same origin (unless the target domain supports CORS). JSONP would be an…
-
3
votes2
answers223
viewsA: Working with Iframe
Just use the event onload of iframe. Example: function onIframeCompleto() { alert('Site terminou de carregar.'); } <iframe src="http://example.org" onload="onIframeCompleto()"></iframe>…
-
7
votes2
answers618
viewsA: How can we not allow indexing by search engines?
You can use a file robots txt. at the root of your web directory with the following content: User-agent: * Disallow: / Remembering that robots.txt is only one tip so Crawler doesn’t index that page.…
-
3
votes1
answer115
viewsA: Opening "menu" at the point that was clicked
The position where the click occurred (relative to the document) is passed in event.pageX and event.pageY. An example of what it could look like: Comments on the code…
jqueryanswered André Ribeiro 5,137 -
2
votes1
answer2890
viewsA: How to make a dropdown menu open by clicking on it and closing by taking the mouse off it
To close while taking the mouse off the dropdown, you can use the event mouseleave. The main changes would be in the event click of botao: botao.on('click', function(event){…
-
3
votes2
answers1309
viewsA: Highlight selected row of the table
An alternative with pure Javascript: Comments on the code var cbs = document.getElementsByClassName('cb'); function cbClick() { var input = document.querySelector('input[data-id="' +…
-
8
votes4
answers4908
viewsA: What is the cost of using the Google Maps API to create routes?
There is a free version of the API. According to the documentation, the differences of the free and paid version are as follows:: Users of the free API: 2,500 route requests per day. Up to 8…
-
2
votes2
answers313
viewsA: addClass to an element above the hierarchy
To access the above element in the hierarchy you can use the function .parent(): $( "a.botao" ).click(function() { $( "#inner" ).parent().addClass( "move-left" ); }); #inner .move{background:none;}…
-
4
votes2
answers534
viewsA: Problem with function that generates friendly url
To clear anything you want to put in a URL you can use the following function (which uses iconv): function sanitize_title($title) { // substitui espaços por "-" $title = preg_replace('#\s+#', '-',…
-
2
votes1
answer74
viewsA: Edit url user profile friendly
Would look like this: # Rotas dos Users RewriteRule ^users/([a-zA-Z-0-9-_]+)$ index.php?controller=perfil&option=user_id&user_id=$1 RewriteRule ^users/([a-zA-Z-0-9-_]+)/edit$…
-
5
votes2
answers4683
viewsA: AJAX post request with Angularjs
You can use the service $http angularjs. In your controller, declare the service dependency $http: .controller('TesteCtrl', ['$scope', '$http', function($scope, $http){ ... Your javascript object…
-
3
votes1
answer880
viewsA: Place div with image on another div
You forgot to put position: relative; in class .produtos-wrapper of your website. .produtos-wrapper{ position:relative; } This makes the Divs with position: absolute; inside .produtos-wrapper stand…
cssanswered André Ribeiro 5,137 -
9
votes2
answers1261
viewsA: Is there any way to detect that an attribute has been changed in HTML?
This can be done using MutationObserver. When creating Mutationobserver you specify a callback that will be called when there is a change in the DOM. Using the method observe you specify which…
-
3
votes3
answers3387
viewsA: Unlock field when selecting Chekbox
You can set a class for the checkboxes and then set the onclick of all of them in a single function. In the example below I used a custom attribute ("data-id") to associate checkboxes with inputs.…
-
2
votes1
answer923
viewsA: How to sort and filter queries between two tables?
The problem is you’re making one select to find friends and then making another select individual per friend. The results come sorted by date, but as a query is made for each friend, each set comes…
-
1
votes1
answer121
viewsA: Conversion of STRING, Writeprocessmemory()
You need to convert the hexadecimal string typed by the user into an integer before moving to the function. The way you did, what’s being passed is address of the hexadecimal string and not the…
c++answered André Ribeiro 5,137 -
1
votes1
answer124
viewsA: Problem in Friendly Url
You cannot use twice exactly the same pattern because apache will only consider the first one. You can add a /ver (or something like) at the end of the URL to differentiate the operation. Ex.:…
-
4
votes1
answer175
viewsA: Friendly URL does not load content
Your page does not load because it gives javascript error. Since your user-friendly URL contains a "subdirectory", the relative paths of your files .js end up being invalid. You need to add a tag…