Posts by Franchesco • 5,144 points
95 posts
-
4
votes2
answers1308
viewsA: Horizontal ruler with text
Here’s a solution simulating a <hr> centered: .linhaComTexto { width: 100%; height: 20px; border-bottom: 1px solid black; text-align: center; } .linhaComTexto > span { font-size: 40px;…
-
5
votes2
answers877
viewsA: How to transform the value of a variable into the name of an object’s property?
If I understand correctly, you want to create the attribute in the object b which is worth a. So you can do it like this: var a = 'foo'; var b = {}; b[a] = '2';…
javascriptanswered Franchesco 5,144 -
6
votes3
answers1548
viewsA: How to enable and disable textarea with javascript?
Just use the attribute document.getElementById("id").disabled: function toggle(enable) { document.getElementById("obs").disabled = enable; } <button id='btn_habilitar'…
-
27
votes6
answers3379
viewsA: How to find out if the year is leap in PHP?
Another way is to use the function date with the parameter L returning 1 if you are in leap year, 0 otherwise. Example for current year: echo date('L'); For a specific year: $ano = 2007; $bissexto=…
-
11
votes1
answer6278
viewsA: How to filter the file format by input type file?
Use the attribute accept. Example accepting only files .xls: <input type="file" name="meuInput" accept=".xls" /> The values of the attribute can be: File extension (.xls, . jpg); audio/* - all…
-
7
votes2
answers7168
viewsA: How to discover the version of my C/C++ on the Linux operating system?
To know your C compiler version, this command must work: gcc --version or gcc -v Just type into a Linux terminal. Note that the C compiler, C++compiler, libc and libstdc++ are two separate things.…
-
9
votes1
answer494
viewsA: Add data from a column
Use the command SUM() adding up the values of a column: SELECT SUM(`valortotal`) as 'Valor Total' FROM produtos WHERE id_venda = 1; See working here: http://sqlfiddle.com/#! 9/bb5d8/2…
-
5
votes1
answer214
viewsA: Undo click of jQuery parent element
Just insert a stopPropagation(); after the alert('b'): $("#link").on('click',function(event){ alert('link'); }); $("#b").on('click',function(event){ alert('b'); event.stopPropagation(); });…
-
3
votes1
answer177
viewsA: What is the "behavior" attribute in CSS for?
Yes, it only works for Internet Explorer. It’s a Microsoft extension for CSS. What does he do? Arrow or search the location of an element’s behavior script Dynamic HTML (DHTML). Usually . Htc files,…
-
4
votes2
answers738
viewsA: Make a change to a div by checking a checkbox
You can do it like this: function mudaDiv(el) { document.getElementsByClassName("bg-yellow")[0].style.backgroundColor = el.checked ? "blue" : ""; } <label style="margin-bottom: 10px;"> <div…
-
1
votes2
answers261
viewsA: Javascript run with certain resolution
You can use the object window screen. to catch the screen size. In it you can use the properties width and height to get the screen size. Example: document.getElementById("width").innerHTML =…
-
1
votes1
answer41
viewsA: How to search a text drive slide
The effect used on the website you referenced is done using the tag marquee. But note that she is obsolete and may not work on browsers current. An example of how it works: <marquee…
-
6
votes2
answers249
viewsQ: How to specify that the constructor type is equal to the one declared in the class?
I created an object that accepts a list of any kind, like this: class Grid<T> { private Integer count; private Integer offset; private Integer limit; private List<T> list; private T…
-
5
votes1
answer431
viewsA: Why does ORDER BY RAND() slow down the query? Is there another alternative?
It takes time because it works in a way that needs to generate a random number for each row of the table. Then he sorts these lines and returns one of them, according to these random numbers. So the…
-
7
votes3
answers767
viewsA: Netbeans IDE: Warning Message
It is a hint that your method could be better, perhaps by dividing it into sub-methods. But this does not need to be followed to the letter and does not always mean that your code can be improved.…
-
3
votes2
answers2503
viewsA: Javascript, action on a selected text
There’s an example using pure javascript: function selecionaTexto() { var textArea = document.getElementById('texto'); var selectedText; if (textArea.selectionStart != undefined) { //Se tiver algo…
-
4
votes1
answer98
viewsA: Show total value
I saw that you already solved the problem. But I will leave the answer as alternative. var valorSeguro = 500.00; var valorPacote = 1200.00; $('input:radio[name="Seguro"]').change( function() { if…
-
2
votes1
answer952
viewsA: How to calculate the value of one cell only what exceeds the other
Just make a condition if it’s more than 2.00 make a difference, or else the value is: A1 = 2,75 B1 = SE(A1>2;A1-2;A1) B1 = 0,75 See more details about the function SE here.…
-
0
votes1
answer377
viewsA: Error while changing path to codeigniter views folder!
Open the file Loader.php which is in the folder ./system/core/Loader.php and change the following line (usually on line 130 of version 2.0): $this->_ci_view_paths = array(APPPATH.'views/' =>…
-
2
votes2
answers1103
viewsA: Javascript - Pick up object id from a list generated with PHP and HTML
In your object must have a method of type getID(). So you can do it like this: <a href="#" class="button" name="enviar" onclick="enviar(<?php echo $contato->getID(); ?>);" ><img…
-
1
votes2
answers2044
viewsA: calculate timestamp difference between two dates
When messing with dates I recommend using the library Momenjs, because she does all the 'heavy' work involving calculating dates. With it you can use the function diff() to calculate the difference…
javascriptanswered Franchesco 5,144 -
5
votes1
answer77
viewsA: Code snippet in Try
It’s not the same. The second is a try with Resources, introduced in Java 7, which briefly is a try declaring an object AutoCloseable, in your case a FileInputStream. This means that if there is…
-
7
votes3
answers198
viewsA: How to humanize javascript dates
I advise you to use the plugin momentjs: Then it’s easy, just use the function Duration() to calculate the current time duration with the desired date: var hoje = moment(); var dia =…
-
6
votes2
answers679
viewsA: Menu to select color
With HTML5 simply use input guy color: Escolha a cor: <input type="color"> Note: not all browsers support this kind of input. Or else use a plugin Javascript, as the http://jscolor.com/…
-
2
votes1
answer386
viewsA: Focus on jQuery Validate invalid field
The Focus in the invalid fields should already be enabled by default. But you can force the activation by setting in the options, thus: focusInvalid: true For more information see the documentation…
-
1
votes2
answers2141
viewsA: Modify variable when clicking javascript and PHP
You have to put a specific ID for each button. Then at the event onclick pass this as a parameter. Then in the javascript function just take the number by the value of the element. Example: function…
-
4
votes2
answers8912
viewsA: Add days to Javascript Date() in dd/mm/yyyy format
One of the ways to solve this problem would be like this: var dias = 2; var dataAtual = new Date(); var previsao = dataAtual.setDate(dataAtual.getDate() + dias); var dataBrasil = previsao.getDate()…
javascriptanswered Franchesco 5,144 -
5
votes1
answer862
viewsA: Capture Windows Clipboard with JAVA
Yeah, you can use the class Toolkit. Here’s an example: import java.awt.HeadlessException; import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import…
-
2
votes1
answer78
viewsA: Export a search result to . Txt
Just click on the button 'Export recordset to an External file':
-
5
votes5
answers20983
viewsA: Grab content from another page by javascript or jquery
You can use the function load(). Example of use: $( "#resultado" ).load( "ajax/teste.html #container" ); That is, the ID element resultado will receive the content that is in the ID element…
-
2
votes2
answers471
viewsA: Decrease float accuracy in Javascript?
Use the function Math.round() which returns the value of the nearest integer. Math.round(num * 100) / 100 You can also use the function toFixed(): parseFloat("123.456").toFixed(2); // Se for uma…
-
4
votes3
answers4457
viewsA: Calling Java application via PHP
You can use the function exec() to call a Java program or any other program that is on your server. But caring for, this function can be dangerous If you let the user execute any command, for…
-
3
votes2
answers784
viewsA: Configure IP for server access using Hibernate
If I understood the question correctly I went through a similar situation some time ago. In the case the solution I used was the following: Create a map with different file properties…
-
1
votes1
answer685
viewsA: How to read an XML file from the server
Having the URL of the XML file, for example www.seusite.com.br/arquivo.xml you can use the SAX API. An example (not tested): String url = "http://www.seusite.com.br/arquivo.xml"; XMLReader myReader…
-
1
votes4
answers15572
viewsA: What is the super() function for;
Serves to call the builder of the parent class of the class who is calling the super(); It can also be called with parameters if the parent class has a constructor with the proper parameter, such as…
-
1
votes1
answer1768
viewsA: How do I get a form to send email to 2 recipients?
The hidden email you inform on header of the message, example: // Vários 'para' separados por vírgula $para = '[email protected]' . ', '; $para .= '[email protected]'; // Assunto $assunto=…
phpanswered Franchesco 5,144 -
3
votes2
answers425
viewsA: How to get the last (max) tabindex from an html form using jQuery
You can check if the last element is with Focus, if yes, by pressing TAB or ENTER sends Focus pro first. Example: $(':input').keydown( function(event) { if ( (event.which === 13 || event.which ===…
-
3
votes3
answers1490
viewsA: Changing the modal content
Using jQuery or Javascript you can pass the content of the modals to a function within the 'learn more': function funcao(conteudo, titulo) { $("#titulo").html(titulo); $("#conteudo").html(conteudo);…
-
3
votes2
answers75
viewsA: Take the form information and send it to e-mail
Unable to send email using Javascript only. You should use a server language for this, for example PHP. But you can use the command window.open('mailto:[email protected]'); to open the standard…
-
8
votes2
answers17110
viewsA: How to adapt this login system to Javascript?
First one alert: avoid authenticating through Javascript, because it is extremely insecure, an example, just someone view the source code of the page to see the user and password, and other…
-
4
votes2
answers5569
viewsA: How to read a digital certificate file with php
You can use the function openssl_x509_parse() to read the certificate and then return the information in the form of array. For example: $certpath = "certificado.cer"; $certinfo =…
-
3
votes2
answers2842
viewsA: Accept only multiples of X in input
You can do in the event blur of input, which checks every time it loses the phocus: var X = 2; $("#entrada").blur(function() { var numero = parseInt($(this).val()); if (!isNaN(numero)) { if (numero…
jqueryanswered Franchesco 5,144 -
1
votes3
answers18417
viewsA: How to catch the child element
There are several ways to get the result: var elementopai = $(this).next().attr('class'); // Busca o próximo irmão var elementopai = $(this).prev().attr('class'); // Busca o irmão anterior. In your…
-
0
votes2
answers1025
viewsA: Close get request as soon as you start another
You can save the call get for a variable: var request = $.ajax({ type: 'POST', url: 'someurl', success: function(result){} }); So every time you make a request, just check the variable request. If…
-
0
votes2
answers256
viewsA: Display the class of different tags from one ID each click
First of all you must define id unique to each element. But what you want can be done like this: $("li").click(function () { alert($(this).attr("class")); }); <script…
-
3
votes3
answers828
viewsA: How do I generate a hash in the client-side?
Coding the password on the client side and sending it to the server will not give you much more security. If an intruder captures this coded password he may use exactly this password in the future,…
-
2
votes2
answers600
viewsA: Enable select HTML with
We had to select the select in function querySelector of cbClick: var cbs = document.getElementsByClassName('cb'); function cbClick() { var input = document.querySelector('input[data-id="' +…
-
2
votes1
answer503
viewsA: Remove selection color from Jtable’s line?
You can create a redenderer customized to the table. Example: class CustomRenderer extends DefaultTableCellRenderer { @Override public Component getTableCellRendererComponent(JTable table, Object…
-
3
votes3
answers3387
viewsA: Unlock field when selecting Chekbox
You can use a function in the event onchange of checkbox passing the this. Whereas there will always be a input after the checkbox, then in the function just use the nextElementSibling[1] to catch…
-
4
votes3
answers8270
viewsA: Convert natural number to binary recursively
You must set a limit for the function. In this case the limit is when the number to be divided by zero or less. You can do the following: int funcao(int n, int pot, int bin) { bin += (n % 2)* pot; n…